Skip to main content

OwnedFd

Struct OwnedFd 

Source
pub struct OwnedFd { /* private fields */ }
Expand description

Un descripteur de fichier possédé, fermé automatiquement à Drop.

OwnedFd est le garant RAII de la couche 0 : tant qu’il vit, le FD est garanti ouvert ; quand il est détruit, close(2) est appelé une seule fois. Pour récupérer une éventuelle erreur de fermeture, consommer le FD via air_sys_syscall::fs::close plutôt que de laisser jouer le Drop.

Représentation : #[repr(transparent)] sur un RawFd (i32) contenant le FD brut — motif binaire identique à std::os::fd::OwnedFd. Pas de niche sur stable (cf. doc du module) : size_of::<Option<OwnedFd>>() == 8.

Trait Implementations§

Source§

impl AsFd for OwnedFd

Source§

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

Emprunte le FD pour la durée de l’emprunt &self.
Source§

impl AsRawFd for OwnedFd

Source§

fn as_raw_fd(&self) -> RawFd

Retourne le FD brut sous-jacent.
Source§

impl Debug for OwnedFd

Source§

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

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

impl Drop for OwnedFd

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl FromRawFd for OwnedFd

Source§

unsafe fn from_raw_fd(fd: RawFd) -> Self

§Safety
  • fd doit être un descripteur ouvert et valide ;
  • fd doit être différent de -1 (sentinelle kernel interdite) ;
  • l’appelant cède l’ownership : fd ne doit plus être fermé ailleurs, sous peine de double-close (faille de sécurité classique).
Source§

impl IntoRawFd for OwnedFd

Source§

fn into_raw_fd(self) -> RawFd

Consomme self et restitue le FD brut sans le fermer.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.