pub trait GenericOwnedBlock:
Clone
+ Debug
+ Send
+ Sync
+ Into<OwnedBlock>
+ Any
+ 'static {
type Header: GenericOwnedBlockHeader;
type Body: GenericOwnedBlockBody;
type Block<'a>: GenericBlock<'a>
where Self: 'a;
const SHARD_KIND: RealShardKind;
// Required methods
fn split(self) -> (Self::Header, Self::Body);
fn header(&self) -> &Self::Header;
fn body(&self) -> &Self::Body;
fn from_parts(
header: Self::Header,
body: Self::Body,
) -> Result<Self, (Self::Header, Self::Body)>;
fn from_buffers(
header: SharedAlignedBuffer,
body: SharedAlignedBuffer,
) -> Result<Self, (SharedAlignedBuffer, SharedAlignedBuffer)>;
fn from_buffer(
buffer: SharedAlignedBuffer,
) -> Result<Self, SharedAlignedBuffer>;
fn block(&self) -> Self::Block<'_>;
}ab_core_primitives.Expand description
Generic owned block.
Can’t be implemented outside of this module, so that code generic over owned blocks can rely on the header corresponding to the body, like with concrete owned blocks.
Required Associated Constants§
Sourceconst SHARD_KIND: RealShardKind
const SHARD_KIND: RealShardKind
Shard kind
Required Associated Types§
Sourcetype Header: GenericOwnedBlockHeader
type Header: GenericOwnedBlockHeader
Block header type
Sourcetype Body: GenericOwnedBlockBody
type Body: GenericOwnedBlockBody
Block body type
Sourcetype Block<'a>: GenericBlock<'a>where
Self: 'a,
type Block<'a>: GenericBlock<'a>where
Self: 'a,
Block
Required Methods§
Sourcefn from_parts(
header: Self::Header,
body: Self::Body,
) -> Result<Self, (Self::Header, Self::Body)>
fn from_parts( header: Self::Header, body: Self::Body, ) -> Result<Self, (Self::Header, Self::Body)>
Create owned block from a header and a body.
Returns them back if the header doesn’t correspond to the body.
Sourcefn from_buffers(
header: SharedAlignedBuffer,
body: SharedAlignedBuffer,
) -> Result<Self, (SharedAlignedBuffer, SharedAlignedBuffer)>
fn from_buffers( header: SharedAlignedBuffer, body: SharedAlignedBuffer, ) -> Result<Self, (SharedAlignedBuffer, SharedAlignedBuffer)>
Create owned block from buffers.
Returns them back if they don’t contain a header and a body of a block.
Sourcefn from_buffer(buffer: SharedAlignedBuffer) -> Result<Self, SharedAlignedBuffer>
fn from_buffer(buffer: SharedAlignedBuffer) -> Result<Self, SharedAlignedBuffer>
Create owned block from a buffer with a whole block, see Block::try_from_bytes() for the
layout.
Headers are usually kept in memory much longer than bodies, so the header is copied into a
separate allocation, while the body references buffer. Returns buffer back if it doesn’t
contain exactly a block.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".