pub struct InstanceRegistry { /* private fields */ }Expand description
Registry view tied to a specific guest instance.
Implementations§
Source§impl InstanceRegistry
impl InstanceRegistry
Sourcepub fn load_mailbox(
&mut self,
mb: &'static GuestMailbox,
) -> Result<(), RegistryError>
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.
Sourcepub fn registrar(&self) -> InstanceRegistrar
pub fn registrar(&self) -> InstanceRegistrar
Create a lightweight registrar for instance-scoped resources.
Sourcepub fn refresh_mailbox(&self, base: usize)
pub fn refresh_mailbox(&self, base: usize)
Refresh mailbox base pointers after guest memory growth.
Sourcepub fn close_mailbox(&self)
pub fn close_mailbox(&self)
Close the mailbox to prevent further guest wake-ups.
Sourcepub fn set_memory_limit(&mut self, bytes: usize) -> Result<(), RegistryError>
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.
Sourcepub fn insert<T: Send + 'static>(
&mut self,
entry: T,
owner: Option<ResourceId>,
kind: ResourceType,
) -> Result<usize, RegistryError>
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.
Sourcepub fn insert_id(&mut self, id: ResourceId) -> Result<usize, RegistryError>
pub fn insert_id(&mut self, id: ResourceId) -> Result<usize, RegistryError>
Insert a resource ID and return its slot index.
Sourcepub fn entry(&self, idx: usize) -> Option<ResourceId>
pub fn entry(&self, idx: usize) -> Option<ResourceId>
Retrieve the entry for the given slot.
Sourcepub fn with<T: 'static, R>(
&self,
idx: ResourceId,
f: impl FnOnce(&mut T) -> R,
) -> Option<R>
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.
Sourcepub fn insert_extension<T: Any + Send + Sync>(
&mut self,
value: T,
) -> Result<(), RegistryError>
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.
Sourcepub fn detach_slot(&mut self, idx: usize) -> Option<ResourceId>
pub fn detach_slot(&mut self, idx: usize) -> Option<ResourceId>
Remove a slot entry without deleting the underlying resource.
Sourcepub fn waker(&self, task_id: usize) -> Option<Waker>
pub fn waker(&self, task_id: usize) -> Option<Waker>
Produce a waker for the specified guest task if the mailbox is available.
Sourcepub fn mailbox(&self) -> Option<&'static GuestMailbox>
pub fn mailbox(&self) -> Option<&'static GuestMailbox>
Access the guest mailbox backing async wake-ups.
Sourcepub fn registry_arc(&self) -> Arc<Registry>
pub fn registry_arc(&self) -> Arc<Registry>
Clone the underlying global registry reference.
Sourcepub fn set_process_id(
&mut self,
process_id: ResourceId,
) -> Result<(), RegistryError>
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.
Sourcepub fn grant_session_resource(
&self,
session_slot: usize,
capability: Capability,
resource: ResourceId,
) -> Result<bool, KernelError>
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.
Sourcepub fn revoke_session_resource(
&self,
session_slot: usize,
capability: Capability,
resource: ResourceId,
) -> Result<Result<bool, SessionError>, KernelError>
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.
Sourcepub fn insert_future(
&mut self,
state: Arc<FutureSharedState<GuestResult<Vec<u8>>>>,
) -> Result<usize, RegistryError>
pub fn insert_future( &mut self, state: Arc<FutureSharedState<GuestResult<Vec<u8>>>>, ) -> Result<usize, RegistryError>
Insert a guest future and return its handle.
Sourcepub fn remove_future(
&mut self,
handle: usize,
) -> Option<Arc<FutureSharedState<GuestResult<Vec<u8>>>>>
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§
Auto Trait Implementations§
impl Freeze for InstanceRegistry
impl RefUnwindSafe for InstanceRegistry
impl Send for InstanceRegistry
impl Sync for InstanceRegistry
impl Unpin for InstanceRegistry
impl UnwindSafe for InstanceRegistry
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.