Skip to main content

BindingRegistry

Struct BindingRegistry 

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

A narrow registry for provider/context pins and binding identity.

§Lock order

There are two lock classes: the registry lock protects registration and current selection; each mechanism lock protects only lifecycle, allocation identities, queued releases, and quarantined ownership. They are never held together. Allocator/capability callbacks, deferred-queue callbacks, waits, and device operations run with neither lock held.

Implementations§

Source§

impl BindingRegistry

Source

pub fn new() -> Result<Self, BindingError>

Source

pub fn register_provider_context( &self, device: DeviceKey, resource: Arc<dyn BindingResource>, ) -> Result<RegisteredProviderContext, BindingError>

Source

pub fn register_authority( &self, device: DeviceKey, resource: Arc<dyn BindingResource>, ) -> Result<RegisteredAuthority, BindingError>

Source

pub fn register_allocator( &self, context: RegisteredProviderContext, authority: RegisteredAuthority, allocator: Arc<dyn DeviceAllocator>, ) -> Result<RegisteredMechanism, BindingError>

Source

pub unsafe fn register_trusted_composite( &self, context: RegisteredProviderContext, authority: RegisteredAuthority, allocator: Arc<dyn DeviceAllocator>, ) -> Result<RegisteredMechanism, BindingError>

Register a transparent/composite wrapper as one trusted coherent bundle.

§Safety

The registrar must ensure ordinary allocation, optional capabilities, and canonical release all reach one coherent device mechanism, authority, and provider context. Rust cannot prove that a hostile split-inner wrapper satisfies this raw-pointer contract.

Source

pub fn select(&self, mechanism: RegisteredMechanism) -> Result<(), BindingError>

Make mechanism the mechanism that later bind(device) calls use.

A mechanism can be retired or lost between validation and publication, so the candidate is re-checked after it is published. When that re-check fails the selection is withdrawn, and the withdrawal never leaves a dead or unregistered mechanism selected: it will not overwrite a newer selection, restores the previous selection only while that is still registered and Active, and otherwise clears the selection so a later registration for the device can heal it.

Source

pub fn bind(&self, device: DeviceKey) -> Result<MemoryBinding, BindingError>

Source

pub fn bind_registered( &self, mechanism: RegisteredMechanism, ) -> Result<MemoryBinding, BindingError>

Source

pub fn retire(&self, mechanism: RegisteredMechanism) -> Result<(), BindingError>

Stop issuing new work through mechanism.

Existing allocations keep the original allocator/context/authority pinned and may still use MemoryBinding::release explicitly.

The lifecycle is made terminal before the selection is dropped. The two lock classes cannot be held together, so the reverse order leaves a window in which a concurrent select that already validated this mechanism publishes it after the clear and still observes Active at its own re-check, wedging the device on a retired selection. Retiring first means any such select must fail its re-check and withdraw itself.

Source

pub fn invalidate_device( &self, device: DeviceKey, reason: impl Into<Arc<str>>, ) -> Result<(), BindingError>

Invalidate every mechanism and binding for device.

This method changes identity/lifetime state only. It does not invoke a device callback, free physical memory, release a lease, or refund quota.

Like BindingRegistry::retire, every affected mechanism is made terminal before the selection is dropped, so a select racing device loss cannot leave a lost mechanism selected. Only a selection naming a mechanism this call actually invalidated is dropped, so a mechanism registered after this call returns is never deselected by it. A registration that lands while this call is in flight may still end up unselected, because the slot it tried to claim was held by an identity this call then dropped; that fails closed, and the next registration or explicit BindingRegistry::select restores a selection.

Source

pub fn confirm_context_terminated( &self, context: RegisteredProviderContext, ) -> Result<(), BindingError>

Record externally observed provider-context/process termination.

This is the device-loss teardown boundary. Allocation identities become terminal without calling the allocator. Accounting/delegated quota must be reconciled by the owning authority only after its own required process or context termination observation.

Source

pub fn quarantined( &self, mechanism: RegisteredMechanism, ) -> Result<Vec<QuarantinedAllocation>, BindingError>

Ownership this mechanism deliberately retained instead of releasing.

Taking this list never invokes a provider and never calls an allocator.

Source

pub fn remove_provider_context( &self, context: RegisteredProviderContext, ) -> Result<(), BindingError>

Remove the registry’s provider-context pin after all mechanism registrations using it have been removed. Existing binding handles keep their own pin until they retire.

Source

pub fn remove_authority( &self, authority: RegisteredAuthority, ) -> Result<(), BindingError>

Remove the registry’s authority pin after all mechanism registrations using it have been removed. This does not refund charges or delegated quota; the authority owner performs accounting reconciliation separately.

Source

pub fn remove(&self, mechanism: RegisteredMechanism) -> Result<(), BindingError>

Remove a terminal/retired registration once no allocation metadata, queued release, quarantined ownership, or active callback remains. Existing binding/capability handles still pin the entry and resources, but remain inactive.

Queued and quarantined ownership both block removal: a queued request still holds an active-operation pin, and quarantined ownership is reported separately so the caller learns why removal is unsafe rather than seeing a bare lifecycle complaint.

Source

pub fn snapshot( &self, mechanism: RegisteredMechanism, ) -> Result<MechanismSnapshot, BindingError>

Source

pub fn snapshots(&self) -> Result<Vec<MechanismSnapshot>, BindingError>

Snapshot every registered mechanism without exposing the registration map to a process manager.

The registry lock is released before any per-mechanism lock is taken, so the two lock classes remain never-nested.

Trait Implementations§

Source§

impl Clone for BindingRegistry

Source§

fn clone(&self) -> BindingRegistry

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BindingRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> BindingResource for T
where T: Send + Sync + Debug,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.