rutabaga_gfx/rutabaga_os/sys/stub/
descriptor.rs

1// Copyright 2020 The ChromiumOS Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use std::fs::File;
6
7use crate::rutabaga_os::descriptor::AsRawDescriptor;
8use crate::rutabaga_os::descriptor::FromRawDescriptor;
9use crate::rutabaga_os::descriptor::IntoRawDescriptor;
10use crate::rutabaga_os::descriptor::SafeDescriptor;
11
12type Error = std::io::Error;
13type Result<T> = std::result::Result<T, Error>;
14
15pub type RawDescriptor = i64;
16
17impl Drop for SafeDescriptor {
18    fn drop(&mut self) {
19        unimplemented!()
20    }
21}
22
23impl SafeDescriptor {
24    /// Clones this descriptor, internally creating a new descriptor. The new SafeDescriptor will
25    /// share the same underlying count within the kernel.
26    pub fn try_clone(&self) -> Result<SafeDescriptor> {
27        Err(Error::last_os_error())
28    }
29}
30
31impl From<SafeDescriptor> for File {
32    fn from(_s: SafeDescriptor) -> File {
33        // Safe because we own the SafeDescriptor at this point.
34        unimplemented!()
35    }
36}
37
38macro_rules! AsRawDescriptor {
39    ($name:ident) => {
40        impl AsRawDescriptor for $name {
41            fn as_raw_descriptor(&self) -> RawDescriptor {
42                unimplemented!()
43            }
44        }
45    };
46}
47
48macro_rules! FromRawDescriptor {
49    ($name:ident) => {
50        impl FromRawDescriptor for $name {
51            unsafe fn from_raw_descriptor(_descriptor: RawDescriptor) -> Self {
52                unimplemented!()
53            }
54        }
55    };
56}
57
58macro_rules! IntoRawDescriptor {
59    ($name:ident) => {
60        impl IntoRawDescriptor for $name {
61            fn into_raw_descriptor(self) -> RawDescriptor {
62                unimplemented!()
63            }
64        }
65    };
66}
67
68// Implementations for File. This enables the File-type to use
69// RawDescriptor, but does not mean File should be used as a generic
70// descriptor container. That should go to either SafeDescriptor or another more
71// relevant container type.
72AsRawDescriptor!(File);
73FromRawDescriptor!(File);
74IntoRawDescriptor!(File);