pub struct BlockBuilder { /* private fields */ }Expand description
Builder for acquiring a fabric block storage lease with capacity constraints.
Use the builder pattern to specify minimum block count requirements,
then call acquire to perform the HELLO
handshake and validate the device capacity.
§Examples
use grafos_std::block::BlockBuilder;
let lease = BlockBuilder::new().min_blocks(256).acquire()?;
assert!(lease.block().num_blocks() >= 256);Implementations§
Source§impl BlockBuilder
impl BlockBuilder
Sourcepub fn min_blocks(self, n: u64) -> Self
pub fn min_blocks(self, n: u64) -> Self
Set the minimum number of blocks required from the device.
If the device reports fewer blocks 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<BlockLease>
pub fn acquire(self) -> Result<BlockLease>
Acquire the block lease by performing the HELLO handshake and verifying that the device meets the requested minimum.
§Errors
FabricError::CapacityExceededif the device block count is less than the configuredmin_blocks.FabricError::Disconnectedif the HELLO handshake fails.
Sourcepub fn attach(lease_id: u128) -> Result<BlockLease>
pub fn attach(lease_id: u128) -> Result<BlockLease>
Attach to an existing block lease by ID.
Instead of allocating a new lease, this queries the host for the
given lease_id and returns a BlockLease bound to it if the
lease is still active. This enables crash recovery: a replacement
tasklet can reconnect to block 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.