pub struct Block {
pub hash: BlockHash,
pub prev_hash: BlockHash,
pub sequence: u64,
pub timestamp: DateTime<Utc>,
pub block_type: BlockType,
pub content: BlockContent,
pub size_bytes: u32,
}Expand description
A content-addressed, immutable block. Once written, never modified. Never deleted.
Fields§
§hash: BlockHashBLAKE3 hash of content (also serves as ID)
prev_hash: BlockHashHash of previous block (integrity chain)
sequence: u64Sequence number (monotonic, gap-free)
timestamp: DateTime<Utc>When this block was created
block_type: BlockTypeBlock type
content: BlockContentThe actual content
size_bytes: u32Size in bytes (for budgeting)
Implementations§
Source§impl Block
impl Block
Sourcepub fn new(
prev_hash: BlockHash,
sequence: u64,
block_type: BlockType,
content: BlockContent,
) -> Self
pub fn new( prev_hash: BlockHash, sequence: u64, block_type: BlockType, content: BlockContent, ) -> Self
Create a new block
Sourcepub fn content_summary(&self) -> String
pub fn content_summary(&self) -> String
Get a short summary of block content (for display).
Sourcepub fn extract_text(&self) -> Option<String>
pub fn extract_text(&self) -> Option<String>
Extract text from block content (for indexing)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Block
impl<'de> Deserialize<'de> for Block
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Block
impl RefUnwindSafe for Block
impl Send for Block
impl Sync for Block
impl Unpin for Block
impl UnsafeUnpin for Block
impl UnwindSafe for Block
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