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.
45use std::fs::File;
67use crate::rutabaga_os::descriptor::AsRawDescriptor;
8use crate::rutabaga_os::descriptor::FromRawDescriptor;
9use crate::rutabaga_os::descriptor::IntoRawDescriptor;
10use crate::rutabaga_os::descriptor::SafeDescriptor;
1112type Error = std::io::Error;
13type Result<T> = std::result::Result<T, Error>;
1415pub type RawDescriptor = i64;
1617impl Drop for SafeDescriptor {
18fn drop(&mut self) {
19unimplemented!()
20 }
21}
2223impl SafeDescriptor {
24/// Clones this descriptor, internally creating a new descriptor. The new SafeDescriptor will
25 /// share the same underlying count within the kernel.
26pub fn try_clone(&self) -> Result<SafeDescriptor> {
27Err(Error::last_os_error())
28 }
29}
3031impl From<SafeDescriptor> for File {
32fn from(_s: SafeDescriptor) -> File {
33// Safe because we own the SafeDescriptor at this point.
34unimplemented!()
35 }
36}
3738macro_rules! AsRawDescriptor {
39 ($name:ident) => {
40impl AsRawDescriptor for $name {
41fn as_raw_descriptor(&self) -> RawDescriptor {
42unimplemented!()
43 }
44 }
45 };
46}
4748macro_rules! FromRawDescriptor {
49 ($name:ident) => {
50impl FromRawDescriptor for $name {
51unsafe fn from_raw_descriptor(_descriptor: RawDescriptor) -> Self {
52unimplemented!()
53 }
54 }
55 };
56}
5758macro_rules! IntoRawDescriptor {
59 ($name:ident) => {
60impl IntoRawDescriptor for $name {
61fn into_raw_descriptor(self) -> RawDescriptor {
62unimplemented!()
63 }
64 }
65 };
66}
6768// 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);