Skip to main content

Fd

Enum Fd 

Source
pub enum Fd<'f> {
    Borrowed(BorrowedFd<'f>),
    Owned(OwnedFd),
}
Expand description

A file-descriptor type wrapper.

Since std::os::fd::BorrowedFd and std::os::fd::OwnedFd types do not implement Serialize and Deserialize. So we provide a wrapper for both that implements these traits.

§D-Bus FD Encoding

In D-Bus, file descriptors are not encoded as their raw numeric values on the wire. Instead, the message body contains a u32 index into an out-of-band array of file descriptors that is transferred alongside the message via SCM_RIGHTS on Unix sockets.

The Deserialize implementation on this type is designed for zvariant’s D-Bus deserializer, which resolves that index through the message’s FD list before calling the serde visitor. Using this type with other deserializers (JSON, CBOR, etc.) is not supported — you would receive a BorrowedFd pointing to whatever FD number happened to be in the payload, which is almost certainly not what you want.

Variants§

§

Borrowed(BorrowedFd<'f>)

§

Owned(OwnedFd)

Implementations§

Source§

impl Fd<'_>

Source

pub fn try_to_owned(&self) -> Result<Fd<'static>, Error>

Try to create an owned version of self.

Source

pub fn try_clone(&self) -> Result<Fd<'_>, Error>

Try to clone self.

Trait Implementations§

Source§

impl AsFd for Fd<'_>

Source§

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

Borrows the file descriptor. Read more
Source§

impl AsRawFd for Fd<'_>

Source§

fn as_raw_fd(&self) -> i32

Extracts the raw file descriptor. Read more
Source§

impl Basic for Fd<'_>

Source§

const SIGNATURE_CHAR: char = 'h'

The type signature, as a character.
Source§

const SIGNATURE_STR: &'static str = "h"

The type signature, as a string.
Source§

fn alignment(format: Format) -> usize

The required padding alignment for the given format. Read more
Source§

impl<'f> Debug for Fd<'f>

Source§

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

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

impl<'de> Deserialize<'de> for Fd<'de>

Source§

fn deserialize<D>( deserializer: D, ) -> Result<Fd<'de>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Fd<'_>

Source§

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

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

impl Eq for Fd<'_>

Source§

impl<'fd, T> From<&'fd T> for Fd<'fd>
where T: AsFd,

Source§

fn from(t: &'fd T) -> Fd<'fd>

Converts to this type from the input type.
Source§

impl<'f> From<BorrowedFd<'f>> for Fd<'f>

Source§

fn from(fd: BorrowedFd<'f>) -> Fd<'f>

Converts to this type from the input type.
Source§

impl From<OwnedFd> for Fd<'_>

Source§

fn from(fd: OwnedFd) -> Fd<'_>

Converts to this type from the input type.
Source§

impl From<OwnedFd> for Fd<'_>

Source§

fn from(owned: OwnedFd) -> Fd<'_>

Converts to this type from the input type.
Source§

impl Hash for Fd<'_>

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Fd<'_>

Source§

fn cmp(&self, other: &Fd<'_>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for Fd<'_>

Source§

fn eq(&self, other: &Fd<'_>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Fd<'_>

Source§

fn partial_cmp(&self, other: &Fd<'_>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Fd<'_>

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a> TryFrom<&'a OwnedValue> for &'a Fd<'a>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from( v: &'a OwnedValue, ) -> Result<&'a Fd<'a>, <&'a Fd<'a> as TryFrom<&'a OwnedValue>>::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Value<'_>> for &'a Fd<'a>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from( value: &'a Value<'_>, ) -> Result<&'a Fd<'a>, <&'a Fd<'a> as TryFrom<&'a Value<'_>>>::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&Value<'a>> for Fd<'a>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from( value: &Value<'a>, ) -> Result<Fd<'a>, <Fd<'a> as TryFrom<&Value<'a>>>::Error>

Performs the conversion.
Source§

impl TryFrom<OwnedValue> for Fd<'static>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from( v: OwnedValue, ) -> Result<Fd<'static>, <Fd<'static> as TryFrom<OwnedValue>>::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<Value<'a>> for Fd<'a>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from( value: Value<'a>, ) -> Result<Fd<'a>, <Fd<'a> as TryFrom<Value<'a>>>::Error>

Performs the conversion.
Source§

impl Type for Fd<'_>

Source§

const SIGNATURE: &'static Signature

The signature for the implementing type, in parsed format. Read more

Auto Trait Implementations§

§

impl<'f> Freeze for Fd<'f>

§

impl<'f> RefUnwindSafe for Fd<'f>

§

impl<'f> Send for Fd<'f>

§

impl<'f> Sync for Fd<'f>

§

impl<'f> Unpin for Fd<'f>

§

impl<'f> UnsafeUnpin for Fd<'f>

§

impl<'f> UnwindSafe for Fd<'f>

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<'de, T> DynamicDeserialize<'de> for T
where T: Type + Deserialize<'de>,

Source§

type Deserializer = PhantomData<T>

A DeserializeSeed implementation for this type.
Source§

fn deserializer_for_signature( signature: &Signature, ) -> Result<<T as DynamicDeserialize<'de>>::Deserializer, Error>

Get a deserializer compatible with this parsed signature.
Source§

impl<T> DynamicType for T
where T: Type + ?Sized,

Source§

fn signature(&self) -> Signature

The type signature for self. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PropValue for T
where T: Type + Into<Value<'static>>,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more