pub struct Descriptor { /* private fields */ }
Expand description
A file descriptor that reference an open file. Also contains flags that change the behaviour of this file descriptor.
Implementations§
source§impl Descriptor
impl Descriptor
pub fn new(file: CompatFile) -> Self
pub fn file(&self) -> &CompatFile
pub fn flags(&self) -> DescriptorFlags
pub fn set_flags(&mut self, flags: DescriptorFlags)
pub fn into_file(self) -> CompatFile
sourcepub fn close(
self,
host: &Host,
cb_queue: &mut CallbackQueue,
) -> Option<Result<(), SyscallError>>
pub fn close( self, host: &Host, cb_queue: &mut CallbackQueue, ) -> Option<Result<(), SyscallError>>
Close the descriptor. The host
option is a legacy option for legacy file.
sourcepub fn dup(&self, flags: DescriptorFlags) -> Self
pub fn dup(&self, flags: DescriptorFlags) -> Self
Duplicate the descriptor, with both descriptors pointing to the same OpenFile
. In
Linux, the descriptor flags aren’t typically copied to the new descriptor, so we
explicitly require a flags value to avoid confusion.
pub fn into_raw(descriptor: Box<Self>) -> *mut Self
pub fn from_raw(descriptor: *mut Self) -> Option<Box<Self>>
sourcepub unsafe fn from_legacy_file(
legacy_file: *mut LegacyFile,
descriptor_flags: OFlag,
) -> Descriptor
pub unsafe fn from_legacy_file( legacy_file: *mut LegacyFile, descriptor_flags: OFlag, ) -> Descriptor
The new descriptor takes ownership of the reference to the legacy file and does not
increment its ref count, but will decrement the ref count when this descriptor is
freed/dropped with descriptor_free()
. The descriptor flags must be either 0 or
O_CLOEXEC
.
If creating a descriptor for a TCP
object, you should use descriptor_fromLegacyTcp
instead. If legacy_file
is a TCP socket, this function will panic.
§Safety
Takes ownership of legacy_file
, which must be safely dereferenceable.
Trait Implementations§
source§impl Clone for Descriptor
impl Clone for Descriptor
source§fn clone(&self) -> Descriptor
fn clone(&self) -> Descriptor
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Descriptor
impl Debug for Descriptor
impl IsSend for Descriptor
impl IsSync for Descriptor
Auto Trait Implementations§
impl Freeze for Descriptor
impl !RefUnwindSafe for Descriptor
impl Send for Descriptor
impl Sync for Descriptor
impl Unpin for Descriptor
impl !UnwindSafe for Descriptor
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more