pub trait IpldBlockOps {
// Required methods
fn block_open(
&mut self,
cid: &Cid<64>,
) -> Result<(u32, BlockStat), ExecutionError>;
fn block_create(
&mut self,
codec: u64,
data: &[u8],
) -> Result<u32, ExecutionError>;
fn block_link(
&mut self,
id: u32,
hash_fun: u64,
hash_len: u32,
) -> Result<Cid<64>, ExecutionError>;
fn block_read(
&self,
id: u32,
offset: u32,
buf: &mut [u8],
) -> Result<i32, ExecutionError>;
fn block_stat(&self, id: u32) -> Result<BlockStat, ExecutionError>;
}Expand description
The IPLD subset of the kernel.
Required Methods§
Sourcefn block_open(
&mut self,
cid: &Cid<64>,
) -> Result<(u32, BlockStat), ExecutionError>
fn block_open( &mut self, cid: &Cid<64>, ) -> Result<(u32, BlockStat), ExecutionError>
Open a block.
This method will fail if the requested block isn’t reachable.
Sourcefn block_create(
&mut self,
codec: u64,
data: &[u8],
) -> Result<u32, ExecutionError>
fn block_create( &mut self, codec: u64, data: &[u8], ) -> Result<u32, ExecutionError>
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: u32,
hash_fun: u64,
hash_len: u32,
) -> Result<Cid<64>, ExecutionError>
fn block_link( &mut self, id: u32, hash_fun: u64, hash_len: u32, ) -> Result<Cid<64>, ExecutionError>
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: u32,
offset: u32,
buf: &mut [u8],
) -> Result<i32, ExecutionError>
fn block_read( &self, id: u32, offset: u32, buf: &mut [u8], ) -> Result<i32, ExecutionError>
Read data from a block.
This method will fail if the block handle is invalid.
Sourcefn block_stat(&self, id: u32) -> Result<BlockStat, ExecutionError>
fn block_stat(&self, id: u32) -> Result<BlockStat, ExecutionError>
Returns the blocks codec & size.
This method will fail if the block handle is invalid.