pub enum BlockBody<'a> {
BeaconChain(BeaconChainBody<'a>),
IntermediateShard(IntermediateShardBody<'a>),
LeafShard(LeafShardBody<'a>),
}Expand description
Block body that together with BlockHeader form a Block
Variants§
BeaconChain(BeaconChainBody<'a>)
Block body corresponds to the beacon chain
IntermediateShard(IntermediateShardBody<'a>)
Block body corresponds to an intermediate shard
LeafShard(LeafShardBody<'a>)
Block body corresponds to a leaf shard
Implementations§
Source§impl<'a> BlockBody<'a>
impl<'a> BlockBody<'a>
Sourcepub fn try_from_bytes(
bytes: &'a [u8],
shard_kind: RealShardKind,
) -> Option<(Self, &'a [u8])>
pub fn try_from_bytes( bytes: &'a [u8], shard_kind: RealShardKind, ) -> Option<(Self, &'a [u8])>
Try to create a new instance from provided bytes for the provided shard index.
bytes must be 16-bytes aligned. Bodies longer than u32::MAX bytes are rejected.
Returns an instance and remaining bytes on success, None if too few bytes were given,
bytes are not properly aligned or input is otherwise invalid.
Sourcepub fn to_owned(self) -> OwnedBlockBody
pub fn to_owned(self) -> OwnedBlockBody
Create an owned version of this body
Sourcepub fn root(&self) -> Blake3Hash
pub fn root(&self) -> Blake3Hash
Compute block body root.
Block body hash is actually a Merkle Tree Root. The leaves are derived from individual fields this enum in the declaration order.
Trait Implementations§
impl<'a> Copy for BlockBody<'a>
Source§impl<'a> From<BeaconChainBody<'a>> for BlockBody<'a>
impl<'a> From<BeaconChainBody<'a>> for BlockBody<'a>
Source§fn from(value: BeaconChainBody<'a>) -> Self
fn from(value: BeaconChainBody<'a>) -> Self
Converts to this type from the input type.
Source§impl<'a> From<IntermediateShardBody<'a>> for BlockBody<'a>
impl<'a> From<IntermediateShardBody<'a>> for BlockBody<'a>
Source§fn from(value: IntermediateShardBody<'a>) -> Self
fn from(value: IntermediateShardBody<'a>) -> Self
Converts to this type from the input type.
Source§impl<'a> From<LeafShardBody<'a>> for BlockBody<'a>
impl<'a> From<LeafShardBody<'a>> for BlockBody<'a>
Source§fn from(value: LeafShardBody<'a>) -> Self
fn from(value: LeafShardBody<'a>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<'a> Forget for BlockBody<'a>
impl<'a> Freeze for BlockBody<'a>
impl<'a> RefUnwindSafe for BlockBody<'a>
impl<'a> Send for BlockBody<'a>
impl<'a> Sync for BlockBody<'a>
impl<'a> Unpin for BlockBody<'a>
impl<'a> UnsafeUnpin for BlockBody<'a>
impl<'a> UnwindSafe for BlockBody<'a>
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