Skip to main content

ExtContext

Struct ExtContext 

Source
pub struct ExtContext<'a> { /* private fields */ }
Expand description

Backend-agnostic context passed to VfsExtension::handle.

Presents the same register/acquire/unregister/cancel_guard surface regardless of whether the call arrived directly (in-process) or over a real RPC session, mirroring the existing direct/remote enum-dispatch pattern used elsewhere in this crate (e.g. AnyVfs, AnyFile).

The direct/remote backing types are intentionally private, so extension code can use this one context without depending on the crate’s wire protocol.

Implementations§

Source§

impl<'a> ExtContext<'a>

Source

pub fn native_capable(&self) -> bool

Whether the peer’s transport can carry native OS handles as out-of-band attachments (see ExtOsHandle).

Always false for direct (in-process) dispatch — there is no wire boundary to cross, so register already produces a zero-cost handle and there is nothing to gain from a native handle.

Source

pub async fn cancel_guard<T, F>( &mut self, operation: F, ) -> Result<T, RequestCancelled>
where F: for<'b> AsyncFnOnce(&'b mut ExtContext<'b>) -> T,

Runs an operation which can observe request cancellation without dropping the handler.

On the remote path this delegates to CallContext::cancel_guard, which cooperatively signals cancellation requested by the peer. On the direct path this is a passthrough (see DirectContext).

Source

pub fn register<T: ExtResource>(&self, value: T) -> ExtGift<T::Marker>

Registers a value in the session’s opaque-object table, returning a handle that can cross the wire (when remote) and be redeemed with acquire/unregister.

The result is an ExtGift, which belongs in a wire position that hands the peer a reference. The peer names it back with ExtGift::cite, and only the resulting ExtCite can be acquired.

§Panics

In remote mode, if a different concrete type has already been registered under T::Marker on this session: a marker must name exactly one resource type, since it is the only type information that crosses the wire.

Source

pub fn acquire<T: ExtResource>( &self, handle: ExtCite<T::Marker>, ) -> Result<ExtGuard<T>, InvalidHandle>

Resolves a citation of a handle previously returned by register.

Source

pub fn unregister<T: ExtResource>( &self, handle: ExtCite<T::Marker>, ) -> Result<Option<T>, InvalidHandle>

Removes a handle previously returned by register, returning the stored value if this was the last reference to it.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for ExtContext<'a>

§

impl<'a> !UnwindSafe for ExtContext<'a>

§

impl<'a> Freeze for ExtContext<'a>

§

impl<'a> Send for ExtContext<'a>

§

impl<'a> Sync for ExtContext<'a>

§

impl<'a> Unpin for ExtContext<'a>

§

impl<'a> UnsafeUnpin for ExtContext<'a>

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.