• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
5 use std::fs::File;
6 
7 use crate::rutabaga_os::descriptor::AsRawDescriptor;
8 use crate::rutabaga_os::descriptor::FromRawDescriptor;
9 use crate::rutabaga_os::descriptor::IntoRawDescriptor;
10 use crate::rutabaga_os::descriptor::SafeDescriptor;
11 
12 type Error = std::io::Error;
13 type Result<T> = std::result::Result<T, Error>;
14 
15 pub type RawDescriptor = i64;
16 
17 impl Drop for SafeDescriptor {
drop(&mut self)18     fn drop(&mut self) {
19         unimplemented!()
20     }
21 }
22 
23 impl SafeDescriptor {
24     /// Clones this descriptor, internally creating a new descriptor. The new SafeDescriptor will
25     /// share the same underlying count within the kernel.
try_clone(&self) -> Result<SafeDescriptor>26     pub fn try_clone(&self) -> Result<SafeDescriptor> {
27         Err(Error::last_os_error())
28     }
29 }
30 
31 impl From<SafeDescriptor> for File {
from(_s: SafeDescriptor) -> File32     fn from(_s: SafeDescriptor) -> File {
33         // Safe because we own the SafeDescriptor at this point.
34         unimplemented!()
35     }
36 }
37 
38 macro_rules! AsRawDescriptor {
39     ($name:ident) => {
40         impl AsRawDescriptor for $name {
41             fn as_raw_descriptor(&self) -> RawDescriptor {
42                 unimplemented!()
43             }
44         }
45     };
46 }
47 
48 macro_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 
58 macro_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.
72 AsRawDescriptor!(File);
73 FromRawDescriptor!(File);
74 IntoRawDescriptor!(File);
75