pub struct Block {
pub header: BlockHeader,
pub data: Bytes,
}Expand description
A storage block containing header and data.
Fields§
§header: BlockHeader§data: BytesImplementations§
Source§impl Block
impl Block
Sourcepub fn new(block_id: BlockId, block_type: BlockType, data: Bytes) -> Self
pub fn new(block_id: BlockId, block_type: BlockType, data: Bytes) -> Self
Create a new block with the given data.
Sourcepub fn verify_checksum(&self) -> bool
pub fn verify_checksum(&self) -> bool
Verify the block’s checksum.
Sourcepub fn update_checksum(&mut self)
pub fn update_checksum(&mut self)
Update the checksum after modifying data.
Sourcepub fn compress(&mut self, compression: CompressionType) -> Result<()>
pub fn compress(&mut self, compression: CompressionType) -> Result<()>
Compress the block data using the specified algorithm.
Sourcepub fn decompress(&mut self) -> Result<()>
pub fn decompress(&mut self) -> Result<()>
Decompress the block data.
Sourcepub fn encrypt(&mut self, encryption: EncryptionType) -> Result<()>
pub fn encrypt(&mut self, encryption: EncryptionType) -> Result<()>
Encrypt the block data using the specified algorithm. Note: Encryption should be applied after compression for better compression ratios.
Sourcepub fn decrypt(&mut self) -> Result<()>
pub fn decrypt(&mut self) -> Result<()>
Decrypt the block data. Note: Decryption should be applied before decompression.
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self>
pub fn from_bytes(data: &[u8]) -> Result<Self>
Deserialize a block from bytes.
Trait Implementations§
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