Trait base::descriptor::AsRawDescriptor

source ·
pub trait AsRawDescriptor {
    // Required method
    fn as_raw_descriptor(&self) -> RawDescriptor;
}
Expand description

Trait for returning the underlying raw descriptor, without giving up ownership of the descriptor.

Required Methods§

source

fn as_raw_descriptor(&self) -> RawDescriptor

Returns the underlying raw descriptor.

Since the descriptor is still owned by the provider, callers should not assume that it will remain open for longer than the immediate call of this method. In particular, it is a dangerous practice to store the result of this method for future use: instead, it should be used to e.g. obtain a raw descriptor that is immediately passed to a system call.

If you need to use the descriptor for a longer time (and particularly if you cannot reliably track the lifetime of the providing object), you should probably consider using SafeDescriptor (possibly along with IntoRawDescriptor) to get full ownership over a descriptor pointing to the same resource.

Trait Implementations§

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.

Implementations on Foreign Types§

source§

impl AsRawDescriptor for File

source§

impl AsRawDescriptor for Stderr

source§

impl AsRawDescriptor for Stdin

source§

impl AsRawDescriptor for Stdout

source§

impl AsRawDescriptor for TcpListener

source§

impl AsRawDescriptor for TcpStream

source§

impl AsRawDescriptor for UdpSocket

source§

impl AsRawDescriptor for OwnedFd

source§

impl AsRawDescriptor for UnixDatagram

source§

impl AsRawDescriptor for UnixListener

source§

impl AsRawDescriptor for UnixStream

source§

impl<T> AsRawDescriptor for Arc<T>
where T: AsRawDescriptor,

Implementors§

source§

impl AsRawDescriptor for &StreamChannel

source§

impl AsRawDescriptor for Event

source§

impl AsRawDescriptor for SharedMemory

USE THIS CAUTIOUSLY. On Windows, the returned handle is not a file handle and cannot be used as if it were one. It is a handle to a the associated file mapping object and should only be used for memory-mapping the file view.

source§

impl AsRawDescriptor for PlatformEvent

source§

impl AsRawDescriptor for NetlinkGenericSocket

source§

impl AsRawDescriptor for SignalFd

source§

impl AsRawDescriptor for TcpSocket

source§

impl AsRawDescriptor for UnixSeqpacket

source§

impl AsRawDescriptor for UnixSeqpacketListener

source§

impl AsRawDescriptor for UnlinkUnixSeqpacketListener

source§

impl AsRawDescriptor for StreamChannel

source§

impl AsRawDescriptor for Tube

source§

impl AsRawDescriptor for FakeTimer

source§

impl AsRawDescriptor for Timer

source§

impl AsRawDescriptor for RecvTube

source§

impl AsRawDescriptor for SendTube

source§

impl AsRawDescriptor for Descriptor

source§

impl AsRawDescriptor for SafeDescriptor

source§

impl<T: EventToken> AsRawDescriptor for EventContext<T>

source§

impl<T: EventToken> AsRawDescriptor for WaitContext<T>

source§

impl<T: AsRawDescriptor> AsRawDescriptor for ScmSocket<T>

impl AsRawDescriptor for UringReactor

impl<T: AsRawDescriptor> AsRawDescriptor for AsyncWrapper<T>

impl AsRawDescriptor for AndroidSparse

impl AsRawDescriptor for ZstdDisk

impl AsRawDescriptor for EventDevice

impl AsRawDescriptor for DisplayAndroid

impl AsRawDescriptor for DisplayStub

impl AsRawDescriptor for DisplayWl

impl AsRawDescriptor for DwlContext

impl AsRawDescriptor for DisplayX

impl AsRawDescriptor for XDisplay

impl AsRawDescriptor for GpuDisplay

impl AsRawDescriptor for Kvm

impl AsRawDescriptor for KvmVcpu

impl AsRawDescriptor for KvmVm

impl AsRawDescriptor for URingContext

impl AsRawDescriptor for Kvm

impl AsRawDescriptor for RunnableVcpu

impl AsRawDescriptor for Vcpu

impl AsRawDescriptor for Vm

impl AsRawDescriptor for FakeTap

impl AsRawDescriptor for Tap

impl AsRawDescriptor for DBusMonitor

impl AsRawDescriptor for Userfaultfd

impl AsRawDescriptor for Device

impl AsRawDescriptor for Vsock

impl<T> AsRawDescriptor for FakeNet<T>

impl<T> AsRawDescriptor for Net<T>

impl AsRawDescriptor for VmMemoryClient

impl AsRawDescriptor for BackingObject

impl AsRawDescriptor for SocketListener

impl AsRawDescriptor for SocketPlatformConnection

impl<R: Req> AsRawDescriptor for Connection<R>

impl<S: Backend> AsRawDescriptor for BackendServer<S>

impl<S: Frontend> AsRawDescriptor for FrontendServer<S>