pub struct MutableBlock<T: BlockMetadata> { /* private fields */ }Expand description
RAII guard for a block in the Reset state.
Holds an Arc<BlockStore<T>> and a BlockId; the slot at that id is in
SlotState::Mutable while this guard exists. Drop returns the slot to
the reset pool.
§Drop behaviour
Dropping a MutableBlock returns the slot to the reset pool. The store’s
release_mutable updates the inflight_mutable gauge.
Implementations§
Source§impl<T: BlockMetadata + Sync> MutableBlock<T>
impl<T: BlockMetadata + Sync> MutableBlock<T>
Sourcepub fn block_size(&self) -> usize
pub fn block_size(&self) -> usize
Returns the fixed block size of this block in tokens.
Sourcepub fn stage(
self,
seq_hash: SequenceHash,
block_size: usize,
) -> Result<CompleteBlock<T>, BlockError<MutableBlock<T>>>
pub fn stage( self, seq_hash: SequenceHash, block_size: usize, ) -> Result<CompleteBlock<T>, BlockError<MutableBlock<T>>>
Transition from Reset to Staged with a pre-computed
SequenceHash and an explicit block_size check.
On size mismatch returns Err(BlockError::BlockSizeMismatch)
containing this MutableBlock so the caller can recover it.
Sourcepub fn complete(
self,
token_block: &TokenBlock,
) -> Result<CompleteBlock<T>, BlockError<MutableBlock<T>>>
pub fn complete( self, token_block: &TokenBlock, ) -> Result<CompleteBlock<T>, BlockError<MutableBlock<T>>>
Transition from Reset to Staged by extracting the
SequenceHash from a TokenBlock.
Trait Implementations§
Source§impl<T: BlockMetadata> Debug for MutableBlock<T>
impl<T: BlockMetadata> Debug for MutableBlock<T>
Source§impl<T: BlockMetadata> Drop for MutableBlock<T>
impl<T: BlockMetadata> Drop for MutableBlock<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for MutableBlock<T>
impl<T> !UnwindSafe for MutableBlock<T>
impl<T> Freeze for MutableBlock<T>
impl<T> Send for MutableBlock<T>
impl<T> Sync for MutableBlock<T>
impl<T> Unpin for MutableBlock<T>
impl<T> UnsafeUnpin for MutableBlock<T>
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