pub struct SafeDescriptor {
    pub(crate) descriptor: RawDescriptor,
}
Expand description

Wraps a RawDescriptor and safely closes it when self falls out of scope.

Fields§

§descriptor: RawDescriptor

Implementations§

source§

impl SafeDescriptor

source

pub fn try_clone(&self) -> Result<SafeDescriptor>

Clones this descriptor, internally creating a new descriptor. The new SafeDescriptor will share the same underlying count within the kernel.

Trait Implementations§

source§

impl AsRawDescriptor for SafeDescriptor

source§

fn as_raw_descriptor(&self) -> RawDescriptor

Returns the underlying raw descriptor. Read more
source§

impl AsRawFd for SafeDescriptor

source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
source§

impl Debug for SafeDescriptor

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for SafeDescriptor

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Drop for SafeDescriptor

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl From<Event> for SafeDescriptor

source§

fn from(evt: Event) -> Self

Converts to this type from the input type.
source§

impl From<File> for SafeDescriptor

source§

fn from(f: File) -> SafeDescriptor

Converts to this type from the input type.
source§

impl From<PlatformEvent> for SafeDescriptor

source§

fn from(evt: PlatformEvent) -> Self

Converts to this type from the input type.
source§

impl From<SafeDescriptor> for Event

source§

fn from(sd: SafeDescriptor) -> Self

Converts to this type from the input type.
source§

impl From<SafeDescriptor> for File

source§

fn from(s: SafeDescriptor) -> File

Converts to this type from the input type.
source§

impl From<SafeDescriptor> for PlatformEvent

source§

fn from(sd: SafeDescriptor) -> Self

Converts to this type from the input type.
source§

impl From<SafeDescriptor> for TcpListener

source§

fn from(s: SafeDescriptor) -> Self

Converts to this type from the input type.
source§

impl From<SafeDescriptor> for TcpStream

source§

fn from(s: SafeDescriptor) -> Self

Converts to this type from the input type.
source§

impl From<SafeDescriptor> for UnixSeqpacket

source§

fn from(s: SafeDescriptor) -> Self

Converts to this type from the input type.
source§

impl From<SafeDescriptor> for UnixStream

source§

fn from(s: SafeDescriptor) -> Self

Converts to this type from the input type.
source§

impl From<SharedMemory> for SafeDescriptor

source§

fn from(sm: SharedMemory) -> SafeDescriptor

Converts to this type from the input type.
source§

impl From<UnixSeqpacket> for SafeDescriptor

source§

fn from(s: UnixSeqpacket) -> Self

Converts to this type from the input type.
source§

impl FromRawDescriptor for SafeDescriptor

source§

unsafe fn from_raw_descriptor(descriptor: RawDescriptor) -> Self

Safety Read more
source§

impl IntoRawDescriptor for SafeDescriptor

source§

impl PartialEq<SafeDescriptor> for SafeDescriptor

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for SafeDescriptor

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl TryFrom<&dyn AsRawDescriptor> for SafeDescriptor

source§

fn try_from(rd: &dyn AsRawDescriptor) -> Result<Self, Self::Error>

Clones the underlying descriptor (handle), internally creating a new descriptor.

WARNING: Windows does NOT support cloning/duplicating all types of handles. DO NOT use this function on IO completion ports, sockets, or pseudo-handles (except those from GetCurrentProcess or GetCurrentThread). See https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-duplicatehandle for further details.

TODO(b/191800567): this API has sharp edges on Windows. We should evaluate making some adjustments to smooth those edges.

§

type Error = Error

The type returned in the event of a conversion error.
source§

impl TryFrom<&dyn AsRawFd> for SafeDescriptor

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(fd: &dyn AsRawFd) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Eq for SafeDescriptor

source§

impl StructuralEq for SafeDescriptor

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsRawDescriptors for Twhere T: AsRawDescriptor,

source§

fn as_raw_descriptors(&self) -> Vec<i32, Global>

Returns the underlying raw descriptors. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,