pub struct MemBuilder { /* private fields */ }Expand description
Builder for acquiring a fabric memory lease with capacity constraints.
Use the builder pattern to specify minimum capacity requirements, then
call acquire to perform the HELLO handshake
and validate the arena size.
§Examples
use grafos_std::mem::MemBuilder;
// Require at least 8 KiB
let lease = MemBuilder::new().min_bytes(8192).acquire()?;
assert!(lease.mem().arena_size()? >= 8192);Implementations§
Source§impl MemBuilder
impl MemBuilder
Sourcepub fn min_bytes(self, n: u64) -> Self
pub fn min_bytes(self, n: u64) -> Self
Set the minimum number of bytes required from the arena.
If the arena reported by the host is smaller than this value,
acquire will return
FabricError::CapacityExceeded.
Sourcepub fn lease_secs(self, secs: u64) -> Self
pub fn lease_secs(self, secs: u64) -> Self
Set the lease TTL in seconds.
Sourcepub fn acquire(self) -> Result<MemLease>
pub fn acquire(self) -> Result<MemLease>
Acquire the memory lease by performing the HELLO handshake and verifying that the arena meets the requested minimum.
§Errors
FabricError::CapacityExceededif the arena size is less than the configuredmin_bytes.FabricError::Disconnectedif the HELLO handshake fails.
Sourcepub fn attach(lease_id: u128) -> Result<MemLease>
pub fn attach(lease_id: u128) -> Result<MemLease>
Attach to an existing memory lease by ID.
Instead of allocating a new lease, this queries the host for the
given lease_id and returns a MemLease bound to it if the
lease is still active. This enables crash recovery: a replacement
tasklet can reconnect to storage that survived the previous
tasklet’s death.
§Errors
FabricError::LeaseExpiredif the lease has expired.FabricError::Revokedif the lease has been revoked.FabricError::Disconnectedif the query fails.