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>
impl<'a> ExtContext<'a>
Sourcepub fn native_capable(&self) -> bool
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.
Sourcepub async fn cancel_guard<T, F>(
&mut self,
operation: F,
) -> Result<T, RequestCancelled>where
F: for<'b> AsyncFnOnce(&'b mut ExtContext<'b>) -> T,
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).
Sourcepub fn register<T: ExtResource>(&self, value: T) -> ExtGift<T::Marker>
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.
Sourcepub fn acquire<T: ExtResource>(
&self,
handle: ExtCite<T::Marker>,
) -> Result<ExtGuard<T>, InvalidHandle>
pub fn acquire<T: ExtResource>( &self, handle: ExtCite<T::Marker>, ) -> Result<ExtGuard<T>, InvalidHandle>
Resolves a citation of a handle previously returned by
register.
Sourcepub fn unregister<T: ExtResource>(
&self,
handle: ExtCite<T::Marker>,
) -> Result<Option<T>, InvalidHandle>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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