pub struct BlockSequence { /* private fields */ }Expand description
Owns a TokenBlockSequence and provides sequence access and token extension methods.
This is a thin wrapper around TokenBlockSequence that provides a convenient API
for the block assignment workflow. It does NOT embed assignments — those are managed
separately by ExternalBlockAssignments.
Implementations§
Source§impl BlockSequence
impl BlockSequence
Sourcepub fn new(tokens: Vec<Token>, block_size: u32, salt_hash: Option<u64>) -> Self
pub fn new(tokens: Vec<Token>, block_size: u32, salt_hash: Option<u64>) -> Self
Creates a new BlockSequence from tokens, block size, and optional salt hash.
Sourcepub fn blocks(&self) -> &[TokenBlock]
pub fn blocks(&self) -> &[TokenBlock]
Returns the completed token blocks.
Sourcepub fn block_size(&self) -> usize
pub fn block_size(&self) -> usize
Returns the block size.
Sourcepub fn total_tokens(&self) -> usize
pub fn total_tokens(&self) -> usize
Returns the total number of tokens (including partial block).
Sourcepub fn sequence(&self) -> &TokenBlockSequence
pub fn sequence(&self) -> &TokenBlockSequence
Returns a reference to the underlying TokenBlockSequence.
Sourcepub fn all_sequence_hashes(&self) -> Vec<SequenceHash> ⓘ
pub fn all_sequence_hashes(&self) -> Vec<SequenceHash> ⓘ
Returns all sequence hashes from completed blocks.
Sourcepub fn extend_tokens(
&mut self,
tokens: Vec<Token>,
) -> Result<Option<Range<usize>>, BlockSequenceError>
pub fn extend_tokens( &mut self, tokens: Vec<Token>, ) -> Result<Option<Range<usize>>, BlockSequenceError>
Extends the sequence with tokens, potentially completing blocks.
Returns the range of newly completed block indices, or None if no blocks completed.
Sourcepub fn append_token(
&mut self,
token: Token,
) -> Result<Option<usize>, BlockSequenceError>
pub fn append_token( &mut self, token: Token, ) -> Result<Option<usize>, BlockSequenceError>
Appends a single token to the sequence.
Returns the index of the completed block if the token completed a block.