Trait fvm::kernel::IpldBlockOps
source · pub trait IpldBlockOps {
// Required methods
fn block_open(&mut self, cid: &Cid) -> Result<(BlockId, BlockStat)>;
fn block_create(&mut self, codec: u64, data: &[u8]) -> Result<BlockId>;
fn block_link(
&mut self,
id: BlockId,
hash_fun: u64,
hash_len: u32,
) -> Result<Cid>;
fn block_read(
&self,
id: BlockId,
offset: u32,
buf: &mut [u8],
) -> Result<i32>;
fn block_stat(&self, id: BlockId) -> Result<BlockStat>;
}
Expand description
The IPLD subset of the kernel.
Required Methods§
sourcefn block_open(&mut self, cid: &Cid) -> Result<(BlockId, BlockStat)>
fn block_open(&mut self, cid: &Cid) -> Result<(BlockId, BlockStat)>
Open a block.
This method will fail if the requested block isn’t reachable.
sourcefn block_create(&mut self, codec: u64, data: &[u8]) -> Result<BlockId>
fn block_create(&mut self, codec: u64, data: &[u8]) -> Result<BlockId>
Create a new block.
This method will fail if the block is too large (SPEC_AUDIT), the codec is not allowed (SPEC_AUDIT), the block references unreachable blocks, or the block contains too many links (SPEC_AUDIT).
sourcefn block_link(
&mut self,
id: BlockId,
hash_fun: u64,
hash_len: u32,
) -> Result<Cid>
fn block_link( &mut self, id: BlockId, hash_fun: u64, hash_len: u32, ) -> Result<Cid>
Computes a CID for a block.
This is the only way to add a new block to the “reachable” set.
This method will fail if the block handle is invalid.
sourcefn block_read(&self, id: BlockId, offset: u32, buf: &mut [u8]) -> Result<i32>
fn block_read(&self, id: BlockId, offset: u32, buf: &mut [u8]) -> Result<i32>
Read data from a block.
This method will fail if the block handle is invalid.
sourcefn block_stat(&self, id: BlockId) -> Result<BlockStat>
fn block_stat(&self, id: BlockId) -> Result<BlockStat>
Returns the blocks codec & size.
This method will fail if the block handle is invalid.