pub struct MemoryManagerImpl {
limits: MemoryLimits,
allocations: Vec<MemoryAllocation>,
stats: Arc<MemoryStats>,
peak_usage: Arc<AtomicU64>,
}
Expand description
WASM Memory Manager
Fields§
§limits:
MemoryLimits§allocations:
Vec<MemoryAllocation>§stats:
Arc<MemoryStats>§peak_usage:
Arc<AtomicU64>
Implementations§
Source§
impl
MemoryManagerImpl
impl MemoryManagerImpl
Source
pub fn
new(limits:
MemoryLimits) -> Self
pub fn new(limits: MemoryLimits) -> Self
Create a new memory manager with the given limits
Source
pub fn
limits(&self) -> &MemoryLimits
pub fn limits(&self) -> &MemoryLimits
Get the current memory limits
Source
pub fn
stats(&self) -> &MemoryStats
pub fn stats(&self) -> &MemoryStats
Get current memory statistics
Source
pub fn
peak_usage_bytes(&self) ->
u64
pub fn peak_usage_bytes(&self) -> u64
Get peak memory usage
Source
pub fn
peak_usage_mb(&self) ->
f64
pub fn peak_usage_mb(&self) -> f64
Get peak memory usage in MB
Source
pub fn
current_usage_bytes(&self) ->
u64
pub fn current_usage_bytes(&self) -> u64
Get current memory usage in bytes
Source
pub fn
current_usage_mb(&self) ->
f64
pub fn current_usage_mb(&self) -> f64
Get current memory usage in MB
Source
pub fn
can_allocate(&self, requested_bytes:
u64) ->
bool
pub fn can_allocate(&self, requested_bytes: u64) -> bool
Check if memory can be allocated
Source
pub fn
allocate_memory( &mut self, instance_id:
&str, memory_type: &str, requested_bytes:
u64, ) ->
Result<u64>
pub fn allocate_memory( &mut self, instance_id: &str, memory_type: &str, requested_bytes: u64, ) -> Result<u64>
Allocate memory for a WASM instance
Source
pub fn
deallocate_memory( &mut self, instance_id:
&str, memory_id: &str, ) ->
Result<bool>
pub fn deallocate_memory( &mut self, instance_id: &str, memory_id: &str, ) -> Result<bool>
Deallocate memory for a WASM instance
Source
pub fn
deallocate_all_for_instance(&mut self, instance_id:
&str) ->
usize
pub fn deallocate_all_for_instance(&mut self, instance_id: &str) -> usize
Deallocate all memory for an instance
Source
pub fn
grow_memory( &mut self, instance_id:
&str, memory_id: &str, additional_bytes:
u64, ) ->
Result<u64>
pub fn grow_memory( &mut self, instance_id: &str, memory_id: &str, additional_bytes: u64, ) -> Result<u64>
Grow existing memory allocation
Source
pub fn
get_allocations_for_instance( &self, instance_id:
&str, ) ->
Vec<&MemoryAllocation>
pub fn get_allocations_for_instance( &self, instance_id: &str, ) -> Vec<&MemoryAllocation>
Get all allocations for an instance
Source
pub fn
is_exceeded(&self) ->
bool
pub fn is_exceeded(&self) -> bool
Check if memory limits are exceeded
Source
pub fn
usage_percentage(&self) ->
f64
pub fn usage_percentage(&self) -> f64
Get memory usage percentage
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MemoryManagerImpl
impl RefUnwindSafe for MemoryManagerImpl
impl Send for MemoryManagerImpl
impl Sync for MemoryManagerImpl
impl Unpin for MemoryManagerImpl
impl UnsafeUnpin for MemoryManagerImpl
impl UnwindSafe for MemoryManagerImpl
Blanket Implementations§
Source§
impl<T>
BorrowMut<T> for T
where T: ?Sized,
impl<T>
BorrowMut<T> for T
where 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
§
impl<T> Instrument for T
impl<T> Instrument for T
§
fn
instrument(self, span: Span) ->
Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§
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>
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>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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>
IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§
fn
into_request(self) ->
Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in
a tonic::Request