Struct base::descriptor::SafeDescriptor
source · 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
impl SafeDescriptor
sourcepub fn try_clone(&self) -> Result<SafeDescriptor>
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
impl AsRawDescriptor for SafeDescriptor
source§fn as_raw_descriptor(&self) -> RawDescriptor
fn as_raw_descriptor(&self) -> RawDescriptor
Returns the underlying raw descriptor. Read more
source§impl AsRawFd for SafeDescriptor
impl AsRawFd for SafeDescriptor
source§impl Debug for SafeDescriptor
impl Debug for SafeDescriptor
source§impl<'de> Deserialize<'de> for SafeDescriptor
impl<'de> Deserialize<'de> for SafeDescriptor
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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
impl Drop for SafeDescriptor
source§impl From<Event> for SafeDescriptor
impl From<Event> for SafeDescriptor
source§impl From<File> for SafeDescriptor
impl From<File> for SafeDescriptor
source§fn from(f: File) -> SafeDescriptor
fn from(f: File) -> SafeDescriptor
Converts to this type from the input type.
source§impl From<OwnedFd> for SafeDescriptor
impl From<OwnedFd> for SafeDescriptor
source§impl From<PlatformEvent> for SafeDescriptor
impl From<PlatformEvent> for SafeDescriptor
source§fn from(evt: PlatformEvent) -> Self
fn from(evt: PlatformEvent) -> Self
Converts to this type from the input type.
source§impl From<SafeDescriptor> for Event
impl From<SafeDescriptor> for Event
source§fn from(sd: SafeDescriptor) -> Self
fn from(sd: SafeDescriptor) -> Self
Converts to this type from the input type.
source§impl From<SafeDescriptor> for File
impl From<SafeDescriptor> for File
source§impl From<SafeDescriptor> for OwnedFd
impl From<SafeDescriptor> for OwnedFd
source§fn from(s: SafeDescriptor) -> Self
fn from(s: SafeDescriptor) -> Self
Converts to this type from the input type.
source§impl From<SafeDescriptor> for PlatformEvent
impl From<SafeDescriptor> for PlatformEvent
source§fn from(sd: SafeDescriptor) -> Self
fn from(sd: SafeDescriptor) -> Self
Converts to this type from the input type.
source§impl From<SafeDescriptor> for TcpListener
impl From<SafeDescriptor> for TcpListener
source§fn from(s: SafeDescriptor) -> Self
fn from(s: SafeDescriptor) -> Self
Converts to this type from the input type.
source§impl From<SafeDescriptor> for TcpStream
impl From<SafeDescriptor> for TcpStream
source§fn from(s: SafeDescriptor) -> Self
fn from(s: SafeDescriptor) -> Self
Converts to this type from the input type.
source§impl From<SafeDescriptor> for UnixSeqpacket
impl From<SafeDescriptor> for UnixSeqpacket
source§fn from(s: SafeDescriptor) -> Self
fn from(s: SafeDescriptor) -> Self
Converts to this type from the input type.
source§impl From<SafeDescriptor> for UnixStream
impl From<SafeDescriptor> for UnixStream
source§fn from(s: SafeDescriptor) -> Self
fn from(s: SafeDescriptor) -> Self
Converts to this type from the input type.
source§fn from(sm: SharedMemory) -> SafeDescriptor
fn from(sm: SharedMemory) -> SafeDescriptor
Converts to this type from the input type.
source§impl From<UnixSeqpacket> for SafeDescriptor
impl From<UnixSeqpacket> for SafeDescriptor
source§fn from(s: UnixSeqpacket) -> Self
fn from(s: UnixSeqpacket) -> Self
Converts to this type from the input type.
source§impl FromRawDescriptor for SafeDescriptor
impl FromRawDescriptor for SafeDescriptor
source§unsafe fn from_raw_descriptor(descriptor: RawDescriptor) -> Self
unsafe fn from_raw_descriptor(descriptor: RawDescriptor) -> Self
Safety Read more
source§impl IntoRawDescriptor for SafeDescriptor
impl IntoRawDescriptor for SafeDescriptor
fn into_raw_descriptor(self) -> RawDescriptor
source§impl PartialEq for SafeDescriptor
impl PartialEq for SafeDescriptor
source§impl Serialize for SafeDescriptor
impl Serialize for SafeDescriptor
source§impl TryFrom<&dyn AsRawDescriptor> for SafeDescriptor
impl TryFrom<&dyn AsRawDescriptor> for SafeDescriptor
source§fn try_from(rd: &dyn AsRawDescriptor) -> Result<Self, Self::Error>
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.
source§impl TryFrom<&dyn AsRawFd> for SafeDescriptor
impl TryFrom<&dyn AsRawFd> for SafeDescriptor
impl Eq for SafeDescriptor
Auto Trait Implementations§
impl RefUnwindSafe for SafeDescriptor
impl Send for SafeDescriptor
impl Sync for SafeDescriptor
impl Unpin for SafeDescriptor
impl UnwindSafe for SafeDescriptor
Blanket Implementations§
source§impl<T> AsRawDescriptors for Twhere
T: AsRawDescriptor,
impl<T> AsRawDescriptors for Twhere
T: AsRawDescriptor,
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
Mutably borrows from an owned value. Read more