Skip to main content

Handle

Struct Handle 

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

An open, classified handle to a filesystem entry obtained via O_PATH|O_NOFOLLOW.

The fd is opened with O_PATH, so it cannot be used for reading; it exists solely to identify the entry (for further openat calls relative to it) and to carry the stat snapshot. A symlink entry is never followed: it yields a Handle with kind() == EntryKind::Symlink.

Implementations§

Source§

impl Handle

Source

pub fn kind(&self) -> EntryKind

The entry’s classification (File / Dir / Symlink / Special).

Source

pub fn dev(&self) -> u64

The device number of the entry.

Source

pub fn ino(&self) -> u64

The inode number of the entry.

Source

pub fn meta(&self) -> &FileMeta

A snapshot of the entry’s metadata at the time the handle was opened.

Source

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

Borrow the underlying file descriptor.

Source

pub fn try_clone(&self) -> Result<Handle>

Duplicate this handle, sharing the same pinned inode via a dup’d (F_DUPFD_CLOEXEC) O_PATH file descriptor and copying the cached classification + stat snapshot.

This is a pure fd dup — it opens nothing, follows nothing, and stats nothing on the filesystem, so it preserves every TOCTOU property of the original O_PATH|O_NOFOLLOW handle (the clone pins the exact same inode and cannot be redirected by a concurrent rename/symlink swap). It lets a walk that classifies an entry once hand an owned handle to a deferred (post-order) step without a second openat/fstatat on the entry.

Read this symlink’s target and metadata from the one pinned O_PATH fd: the target via the empty-path readlinkat (read_link_handle) and the metadata from this handle’s fstat snapshot. Both describe the same pinned inode, so they are a faithful pair (the symlink analogue of Dir::open_file_read’s (File, FileMeta)). Errors if the handle is not a symlink (the empty-path read requires a symlink fd).

Trait Implementations§

Source§

impl Debug for Handle

Source§

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

Formats the value using the given formatter. Read more

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> 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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
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.
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