Struct std::os::wasi::io::BorrowedFd
#[repr(transparent)]pub struct BorrowedFd<'fd> { /* fields omitted */ }
A borrowed file descriptor.
This has a lifetime parameter to tie it to the lifetime of something that owns the file descriptor.
This uses repr(transparent)
and has the representation of a host file descriptor, so it can be used in FFI in places where a file descriptor is passed as an argument, it is not captured or consumed, and it never has the value -1
.
Implementations
impl BorrowedFd<'_>
pub unsafe fn borrow_raw_fd(fd: RawFd) -> Self
Return a BorrowedFd
holding the given raw file descriptor.
Safety
The resource pointed to by fd
must remain open for the duration of the returned BorrowedFd
, and it must not have the value -1
.
Trait Implementations
impl AsFd for BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more
impl AsRawFd for BorrowedFd<'_>
fn as_raw_fd(&self) -> RawFd
Extracts the raw file descriptor. Read more
impl<'fd> Clone for BorrowedFd<'fd>
fn clone(&self) -> BorrowedFd<'fd>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for BorrowedFd<'_>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the value using the given formatter. Read more
impl<'fd> Copy for BorrowedFd<'fd>
Auto Trait Implementations
impl<'fd> RefUnwindSafe for BorrowedFd<'fd>
impl<'fd> Send for BorrowedFd<'fd>
impl<'fd> Sync for BorrowedFd<'fd>
impl<'fd> Unpin for BorrowedFd<'fd>
impl<'fd> UnwindSafe for BorrowedFd<'fd>
Blanket Implementations
impl<T> From<T> for T
pub fn from(t: T) -> T
Performs the conversion.
pub fn into(self) -> U
Performs the conversion.
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
#41263)recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
Performs the conversion.
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
Performs the conversion.
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/os/wasi/io/struct.BorrowedFd.html