pub struct Registry { /* private fields */ }Expand description
Registry of guest resources.
Implementations§
Source§impl Registry
impl Registry
Sourcepub fn instance(self: &Arc<Self>) -> Result<InstanceRegistry, RegistryError>
pub fn instance(self: &Arc<Self>) -> Result<InstanceRegistry, RegistryError>
Create an InstanceRegistry view tied to this registry.
Sourcepub fn add<T: Send + 'static>(
&self,
resource: T,
owner: Option<ResourceId>,
kind: ResourceType,
) -> Result<ResourceHandle<T>, RegistryError>
pub fn add<T: Send + 'static>( &self, resource: T, owner: Option<ResourceId>, kind: ResourceType, ) -> Result<ResourceHandle<T>, RegistryError>
Add a resource to the registry and return its typed handle.
Sourcepub fn reserve(
&self,
owner: Option<ResourceId>,
kind: ResourceType,
) -> Result<ResourceId, RegistryError>
pub fn reserve( &self, owner: Option<ResourceId>, kind: ResourceType, ) -> Result<ResourceId, RegistryError>
Reserve a slot for a resource and return its identifier.
Sourcepub fn initialise<T: Send + 'static>(
&self,
id: ResourceId,
resource: T,
) -> Result<ResourceHandle<T>, RegistryError>
pub fn initialise<T: Send + 'static>( &self, id: ResourceId, resource: T, ) -> Result<ResourceHandle<T>, RegistryError>
Initialise a reserved slot with the given resource.
Sourcepub fn remove<T: 'static>(&self, id: ResourceHandle<T>) -> Option<T>
pub fn remove<T: 'static>(&self, id: ResourceHandle<T>) -> Option<T>
Remove a resource from the registry, returning ownership.
Sourcepub fn discard(&self, id: ResourceId) -> bool
pub fn discard(&self, id: ResourceId) -> bool
Discard a resource entry without attempting to downcast its payload.
Sourcepub fn with<T: 'static, R>(
&self,
id: ResourceHandle<T>,
func: impl FnOnce(&mut T) -> R,
) -> Option<R>
pub fn with<T: 'static, R>( &self, id: ResourceHandle<T>, func: impl FnOnce(&mut T) -> R, ) -> Option<R>
Borrow a resource mutably by erased handle and run a closure with it.
Create or retrieve a shared guest handle for the resource id.
Resolve a shared guest handle into its resource id.
Return the shared guest handle for a resource id, if one exists.
Sourcepub fn metadata(&self, id: ResourceId) -> Option<ResourceMetadata>
pub fn metadata(&self, id: ResourceId) -> Option<ResourceMetadata>
Fetch metadata for a resource.
Sourcepub fn owner(&self, id: ResourceId) -> Option<ResourceId>
pub fn owner(&self, id: ResourceId) -> Option<ResourceId>
Return the recorded owner for a resource.
Sourcepub fn owned_resources(&self, owner: ResourceId) -> Vec<ResourceId> ⓘ
pub fn owned_resources(&self, owner: ResourceId) -> Vec<ResourceId> ⓘ
Return the resources owned by the provided resource id.
Sourcepub fn parent(&self, id: ResourceId) -> Option<ResourceId>
pub fn parent(&self, id: ResourceId) -> Option<ResourceId>
Return the recorded parent for a resource.
Sourcepub fn children(&self, id: ResourceId) -> Vec<ResourceId> ⓘ
pub fn children(&self, id: ResourceId) -> Vec<ResourceId> ⓘ
Return the children linked to the provided resource id.
Sourcepub fn instance_process(&self, instance_id: ResourceId) -> Option<ResourceId>
pub fn instance_process(&self, instance_id: ResourceId) -> Option<ResourceId>
Return the process id associated with the provided instance id.
Sourcepub fn process_instance(&self, process_id: ResourceId) -> Option<ResourceId>
pub fn process_instance(&self, process_id: ResourceId) -> Option<ResourceId>
Return the instance id associated with the provided process id.
Sourcepub fn log_channel(&self, process_id: ResourceId) -> Option<ResourceId>
pub fn log_channel(&self, process_id: ResourceId) -> Option<ResourceId>
Return the registered log channel resource for the process, if present.
Sourcepub fn log_channel_handle(
&self,
process_id: ResourceId,
) -> Option<GuestResourceId>
pub fn log_channel_handle( &self, process_id: ResourceId, ) -> Option<GuestResourceId>
Return the registered log channel handle for the process, if present.
Sourcepub fn register_singleton(
&self,
id: DependencyId,
resource: ResourceId,
) -> Result<bool, RegistryError>
pub fn register_singleton( &self, id: DependencyId, resource: ResourceId, ) -> Result<bool, RegistryError>
Register a singleton dependency identifier against the supplied resource.
Returns false if the identifier or resource is already registered.
Sourcepub fn singleton(&self, id: DependencyId) -> Option<ResourceId>
pub fn singleton(&self, id: DependencyId) -> Option<ResourceId>
Resolve a singleton dependency identifier to its backing resource id.
Auto Trait Implementations§
impl !Freeze for Registry
impl RefUnwindSafe for Registry
impl Send for Registry
impl Sync for Registry
impl Unpin for Registry
impl !UnwindSafe for Registry
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.