pub struct LogicalBlockAssignments<T: BlockMetadata> { /* private fields */ }Expand description
Manages the physical block guards (RAII types) through three ordered collections,
mirroring the block lifecycle state machine:
MutableBlock<T> → CompleteBlock<T> → ImmutableBlock<T>.
Provides the same ordered-collection semantics as
ExternalBlockAssignments but at the guard level rather
than the identity level.
Implementations§
Source§impl<T: BlockMetadata> LogicalBlockAssignments<T>
impl<T: BlockMetadata> LogicalBlockAssignments<T>
Sourcepub fn assigned_count(&self) -> usize
pub fn assigned_count(&self) -> usize
Returns the number of assigned (registered/immutable) blocks.
Sourcepub fn staged_count(&self) -> usize
pub fn staged_count(&self) -> usize
Returns the number of staged (complete) blocks.
Sourcepub fn unassigned_count(&self) -> usize
pub fn unassigned_count(&self) -> usize
Returns the number of unassigned (mutable) blocks.
Sourcepub fn contains(&self, block_id: &BlockId) -> bool
pub fn contains(&self, block_id: &BlockId) -> bool
Checks whether a BlockId is present in any of the three collections.
Sourcepub fn get_assigned(
&self,
index: usize,
) -> Option<(&BlockId, &ImmutableBlock<T>)>
pub fn get_assigned( &self, index: usize, ) -> Option<(&BlockId, &ImmutableBlock<T>)>
Returns the assigned block at the given index (insertion order).
Sourcepub fn get_staged(&self, index: usize) -> Option<(&BlockId, &CompleteBlock<T>)>
pub fn get_staged(&self, index: usize) -> Option<(&BlockId, &CompleteBlock<T>)>
Returns the staged block at the given index (staging order).
Sourcepub fn get_unassigned(
&self,
index: usize,
) -> Option<(&BlockId, &MutableBlock<T>)>
pub fn get_unassigned( &self, index: usize, ) -> Option<(&BlockId, &MutableBlock<T>)>
Returns the unassigned block at the given index (FIFO order).
Sourcepub fn assigned_iter(
&self,
) -> impl Iterator<Item = (&BlockId, &ImmutableBlock<T>)>
pub fn assigned_iter( &self, ) -> impl Iterator<Item = (&BlockId, &ImmutableBlock<T>)>
Iterates over assigned blocks in positional order.
Sourcepub fn staged_iter(&self) -> impl Iterator<Item = (&BlockId, &CompleteBlock<T>)>
pub fn staged_iter(&self) -> impl Iterator<Item = (&BlockId, &CompleteBlock<T>)>
Iterates over staged blocks in staging order.
Sourcepub fn unassigned_iter(
&self,
) -> impl Iterator<Item = (&BlockId, &MutableBlock<T>)>
pub fn unassigned_iter( &self, ) -> impl Iterator<Item = (&BlockId, &MutableBlock<T>)>
Iterates over unassigned blocks in FIFO order.
Sourcepub fn all_block_ids(&self) -> impl Iterator<Item = &BlockId>
pub fn all_block_ids(&self) -> impl Iterator<Item = &BlockId>
Iterates over all block IDs across all three collections in lifecycle order: assigned → staged → unassigned.
Sourcepub fn extend_blocks(
&mut self,
blocks: impl IntoIterator<Item = MutableBlock<T>>,
) -> Result<usize, LogicalBlockAssignmentError<T>>
pub fn extend_blocks( &mut self, blocks: impl IntoIterator<Item = MutableBlock<T>>, ) -> Result<usize, LogicalBlockAssignmentError<T>>
Adds mutable blocks to the unassigned queue.
Two-phase atomic: collects all blocks, validates no duplicate BlockIds across all three collections, then commits to unassigned. On error, all blocks are returned in the error variant (no leaks).
Sourcepub fn extend_assigned(
&mut self,
blocks: impl IntoIterator<Item = ImmutableBlock<T>>,
) -> Result<usize, LogicalBlockAssignmentError<T>>
pub fn extend_assigned( &mut self, blocks: impl IntoIterator<Item = ImmutableBlock<T>>, ) -> Result<usize, LogicalBlockAssignmentError<T>>
Inserts pre-matched immutable blocks directly into the assigned collection.
This is the entry point for blocks retrieved via
BlockManager::match_blocks — blocks that already exist in the
manager’s pools and can skip the unassigned → staged → assigned pipeline.
Two-phase atomic: collects all blocks, validates no duplicate BlockIds across all three collections, then commits to assigned. On error, all blocks are returned in the error variant (no leaks).
Sourcepub fn stage(
&mut self,
sequence_blocks: &[TokenBlock],
) -> Result<usize, BlockError<MutableBlock<T>>>
pub fn stage( &mut self, sequence_blocks: &[TokenBlock], ) -> Result<usize, BlockError<MutableBlock<T>>>
FIFO drain from unassigned, completing each block with the corresponding token block.
Stages min(sequence_blocks.len(), unassigned.len()) blocks. On
BlockError, already-staged blocks remain in staged; the failed block
is returned in the error.
Sourcepub fn register(&mut self, manager: &BlockManager<T>) -> usize
pub fn register(&mut self, manager: &BlockManager<T>) -> usize
Takes all staged blocks (FIFO order), registering each with the block manager and moving them to assigned.
Returns the number of blocks registered.
Sourcepub fn pop_last_unassigned(&mut self) -> Option<(BlockId, MutableBlock<T>)>
pub fn pop_last_unassigned(&mut self) -> Option<(BlockId, MutableBlock<T>)>
LIFO-removes the last unassigned block.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Drops all guards across all three collections (RAII returns blocks to pools).
Sourcepub fn take_assigned(&mut self) -> Vec<(BlockId, ImmutableBlock<T>)>
pub fn take_assigned(&mut self) -> Vec<(BlockId, ImmutableBlock<T>)>
Takes all assigned blocks, returning them as a Vec.
Sourcepub fn take_staged(&mut self) -> Vec<(BlockId, CompleteBlock<T>)>
pub fn take_staged(&mut self) -> Vec<(BlockId, CompleteBlock<T>)>
Takes all staged blocks, returning them as a Vec.
Sourcepub fn take_unassigned(&mut self) -> Vec<(BlockId, MutableBlock<T>)>
pub fn take_unassigned(&mut self) -> Vec<(BlockId, MutableBlock<T>)>
Takes all unassigned blocks, returning them as a Vec.