pub struct WitHost { /* private fields */ }Expand description
Host-side resource tracker for WIT-based WASM plugins.
Enforces a configurable upper bound on the number of concurrently allocated resources to prevent unbounded memory growth in the host.
Thread-safe: uses a CAS loop on an atomic counter so concurrent
allocate calls cannot race past the limit.
Implementations§
Source§impl WitHost
impl WitHost
Sourcepub fn with_max_resources(max: usize) -> Self
pub fn with_max_resources(max: usize) -> Self
Creates a new WitHost with an explicit maximum resource count.
Sourcepub fn allocate(&self, _name: &str) -> Result<(), CamelError>
pub fn allocate(&self, _name: &str) -> Result<(), CamelError>
Allocates a resource slot.
Returns Err(CamelError::ProcessorError) if the resource limit
would be exceeded. Uses a CAS loop to avoid TOCTOU races when
called concurrently from multiple threads.
Sourcepub fn deallocate(&self, _name: &str)
pub fn deallocate(&self, _name: &str)
Deallocates a resource slot, freeing capacity for future allocations.
Sourcepub fn resource_count(&self) -> usize
pub fn resource_count(&self) -> usize
Returns the current number of allocated resources.
Sourcepub fn max_resources(&self) -> usize
pub fn max_resources(&self) -> usize
Returns the configured maximum resource limit.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for WitHost
impl RefUnwindSafe for WitHost
impl Send for WitHost
impl Sync for WitHost
impl Unpin for WitHost
impl UnsafeUnpin for WitHost
impl UnwindSafe for WitHost
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
Mutably borrows from an owned value. Read more