pub struct BlockMetadata {
pub cid: SerializableCid,
pub size: BlockSize,
pub links: usize,
}Expand description
Metadata about a block for indexing and queries.
This lightweight structure contains summary information about a block without holding the actual data. Useful for block indices and caches.
Fields§
§cid: SerializableCidContent identifier of the block
size: BlockSizeSize of the block data in bytes
links: usizeNumber of CID links to other blocks (for DAG nodes)
Implementations§
Source§impl BlockMetadata
impl BlockMetadata
Sourcepub fn new(cid: Cid, size: BlockSize) -> Self
pub fn new(cid: Cid, size: BlockSize) -> Self
Creates new block metadata with the given CID and size.
The number of links is initialized to 0.
Sourcepub fn with_links(self, links: usize) -> Self
pub fn with_links(self, links: usize) -> Self
Sets the number of CID links in this block.
This is useful for DAG nodes that reference other blocks.
Trait Implementations§
Source§impl Clone for BlockMetadata
impl Clone for BlockMetadata
Source§fn clone(&self) -> BlockMetadata
fn clone(&self) -> BlockMetadata
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BlockMetadata
impl Debug for BlockMetadata
Source§impl<'de> Deserialize<'de> for BlockMetadata
impl<'de> Deserialize<'de> for BlockMetadata
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 BlockMetadata
impl RefUnwindSafe for BlockMetadata
impl Send for BlockMetadata
impl Sync for BlockMetadata
impl Unpin for BlockMetadata
impl UnwindSafe for BlockMetadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more