# Struct std::os::unix::io::BorrowedFd
[−][src]

    #[repr(transparent)]pub struct BorrowedFd<'fd> { /* fields omitted */ }

🔬 This is a nightly-only experimental API. (`io_safety` #87074)
This is supported on Unix only.
Expand description

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

[src]

### impl BorrowedFd<'_>

[src]

#### pub unsafe fn borrow_raw_fd(fd: RawFd) -> Self

🔬 This is a nightly-only experimental API. (`io_safety` #87074)

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

[src]

### impl AsFd for BorrowedFd<'_>

[src]

#### fn as_fd(&self) -> BorrowedFd<'_>

🔬 This is a nightly-only experimental API. (`io_safety` #87074)
This is supported on Unix only.

Borrows the file descriptor. Read more

[src]

### impl AsRawFd for BorrowedFd<'_>

[src]

#### fn as_raw_fd(&self) -> RawFd

This is supported on Unix only.

Extracts the raw file descriptor. Read more

[src]

### impl<'fd> Clone for BorrowedFd<'fd>

[src]

#### fn clone(&self) -> BorrowedFd<'fd>

Returns a copy of the value. Read more

1.0.0[src]

#### fn clone_from(&mut self, source: &Self)

Performs copy-assignment from `source`. Read more

[src]

### impl Debug for BorrowedFd<'_>

[src]

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

Formats the value using the given formatter. Read more

[src]

### 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

[src]

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

[src]

#### pub fn type_id(&self) -> TypeId

Gets the `TypeId` of `self`. Read more

[src]

### impl<T> Borrow<T> for T where
T: ?Sized,

[src]

#### pub fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more

[src]

### impl<T> BorrowMut<T> for T where
T: ?Sized,

[src]

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

Mutably borrows from an owned value. Read more

[src]

### impl<T> From<T> for T

[src]

#### pub fn from(t: T) -> T

Performs the conversion.

[src]

### impl<T, U> Into<U> for T where
U: From<T>,

[src]

#### pub fn into(self) -> U

Performs the conversion.

[src]

### impl<T> ToOwned for T where
T: Clone,

#### type Owned = T

The resulting type after obtaining ownership.

[src]

#### pub fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more

[src]

#### pub fn clone_into(&self, target: &mut T)

🔬 This is a nightly-only experimental API. (`toowned_clone_into` #41263)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

[src]

### impl<T, U> TryFrom<U> for T where
U: Into<T>,

#### type Error = Infallible

The type returned in the event of a conversion error.

[src]

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

Performs the conversion.

[src]

### impl<T, U> TryInto<U> for T where
U: TryFrom<T>,

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

The type returned in the event of a conversion error.

[src]

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

Performs the conversion.