Skip to main content

InstanceRegistry

Struct InstanceRegistry 

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

Registry view tied to a specific guest instance.

Implementations§

Source§

impl InstanceRegistry

Source

pub fn load_mailbox( &mut self, mb: &'static GuestMailbox, ) -> Result<(), RegistryError>

Attach a mailbox used for guest async wake-ups.

Returns an error if the instance state is missing.

Source

pub fn registrar(&self) -> InstanceRegistrar

Create a lightweight registrar for instance-scoped resources.

Source

pub fn refresh_mailbox(&self, base: usize)

Refresh mailbox base pointers after guest memory growth.

Source

pub fn close_mailbox(&self)

Close the mailbox to prevent further guest wake-ups.

Source

pub fn set_memory_limit(&mut self, bytes: usize) -> Result<(), RegistryError>

Set a hard memory limit for this instance.

Returns an error if the instance state is missing.

Source

pub fn insert<T: Send + 'static>( &mut self, entry: T, owner: Option<ResourceId>, kind: ResourceType, ) -> Result<usize, RegistryError>

Insert a resource entry and return its slot index.

Source

pub fn insert_id(&mut self, id: ResourceId) -> Result<usize, RegistryError>

Insert a resource ID and return its slot index.

Source

pub fn entry(&self, idx: usize) -> Option<ResourceId>

Retrieve the entry for the given slot.

Source

pub fn with<T: 'static, R>( &self, idx: ResourceId, f: impl FnOnce(&mut T) -> R, ) -> Option<R>

Borrow a resource by table index and apply a closure.

Source

pub fn insert_extension<T: Any + Send + Sync>( &mut self, value: T, ) -> Result<(), RegistryError>

Attach custom extension data to the instance.

Returns an error if the instance state is missing.

Source

pub fn extension<T: Any + Send + Sync>(&self) -> Option<Arc<T>>

Borrow extension data by type.

Source

pub fn remove<T: 'static>(&mut self, idx: usize) -> Option<T>

Remove an entry by slot index.

Source

pub fn detach_slot(&mut self, idx: usize) -> Option<ResourceId>

Remove a slot entry without deleting the underlying resource.

Source

pub fn waker(&self, task_id: usize) -> Option<Waker>

Produce a waker for the specified guest task if the mailbox is available.

Source

pub fn mailbox(&self) -> Option<&'static GuestMailbox>

Access the guest mailbox backing async wake-ups.

Source

pub fn registry(&self) -> &Registry

Get a reference to the global registry.

Source

pub fn registry_arc(&self) -> Arc<Registry>

Clone the underlying global registry reference.

Source

pub fn set_process_id( &mut self, process_id: ResourceId, ) -> Result<(), RegistryError>

Set the process identifier for this instance. Must be called before guest code can create resources.

Returns an error if the instance state is missing.

Source

pub fn grant_session_resource( &self, session_slot: usize, capability: Capability, resource: ResourceId, ) -> Result<bool, KernelError>

Grant a resource capability to the specified session entry.

Source

pub fn revoke_session_resource( &self, session_slot: usize, capability: Capability, resource: ResourceId, ) -> Result<Result<bool, SessionError>, KernelError>

Revoke a resource capability from the specified session entry.

Source

pub fn insert_future( &mut self, state: Arc<FutureSharedState<GuestResult<Vec<u8>>>>, ) -> Result<usize, RegistryError>

Insert a guest future and return its handle.

Source

pub fn remove_future( &mut self, handle: usize, ) -> Option<Arc<FutureSharedState<GuestResult<Vec<u8>>>>>

Remove a future handle, returning the shared state if present.

Trait Implementations§

Source§

impl Drop for InstanceRegistry

Source§

fn drop(&mut self)

Executes the destructor for this type. 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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> 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> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
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