referrerpolicy=no-referrer-when-downgrade
sp_test_primitives

Type Alias DigestItem

Source
pub type DigestItem = DigestItem;
Expand description

The item of a block digest.

Aliased Type§

enum DigestItem {
    PreRuntime([u8; 4], Vec<u8>),
    Consensus([u8; 4], Vec<u8>),
    Seal([u8; 4], Vec<u8>),
    Other(Vec<u8>),
    RuntimeEnvironmentUpdated,
}

Variants§

§

PreRuntime([u8; 4], Vec<u8>)

A pre-runtime digest.

These are messages from the consensus engine to the runtime, although the consensus engine can (and should) read them itself to avoid code and state duplication. It is erroneous for a runtime to produce these, but this is not (yet) checked.

NOTE: the runtime is not allowed to panic or fail in an on_initialize call if an expected PreRuntime digest is not present. It is the responsibility of a external block verifier to check this. Runtime API calls will initialize the block without pre-runtime digests, so initialization cannot fail when they are missing.

§

Consensus([u8; 4], Vec<u8>)

A message from the runtime to the consensus engine. This should never be generated by the native code of any consensus engine, but this is not checked (yet).

§

Seal([u8; 4], Vec<u8>)

Put a Seal on it. This is only used by native code, and is never seen by runtimes.

§

Other(Vec<u8>)

Some other thing. Unsupported and experimental.

§

RuntimeEnvironmentUpdated

An indication for the light clients that the runtime execution environment is updated.

Currently this is triggered when:

  1. Runtime code blob is changed or
  2. heap_pages value is changed.

Implementations

§

impl DigestItem

pub fn dref(&self) -> DigestItemRef<'_>

Returns a ‘referencing view’ for this digest item.

pub fn as_pre_runtime(&self) -> Option<([u8; 4], &[u8])>

Returns Some if this entry is the PreRuntime entry.

pub fn as_consensus(&self) -> Option<([u8; 4], &[u8])>

Returns Some if this entry is the Consensus entry.

pub fn as_seal(&self) -> Option<([u8; 4], &[u8])>

Returns Some if this entry is the Seal entry.

pub fn as_other(&self) -> Option<&[u8]>

Returns Some if self is a DigestItem::Other.

pub fn try_as_raw(&self, id: OpaqueDigestItemId<'_>) -> Option<&[u8]>

Returns the opaque data contained in the item if Some if this entry has the id given.

pub fn try_to<T>(&self, id: OpaqueDigestItemId<'_>) -> Option<T>
where T: Decode,

Returns the data decoded as T, if the id is matching.

pub fn seal_try_to<T>(&self, id: &[u8; 4]) -> Option<T>
where T: Decode,

Try to match this to a Self::Seal, check id matches and decode it.

Returns None if this isn’t a seal item, the id doesn’t match or when the decoding fails.

pub fn consensus_try_to<T>(&self, id: &[u8; 4]) -> Option<T>
where T: Decode,

Try to match this to a Self::Consensus, check id matches and decode it.

Returns None if this isn’t a consensus item, the id doesn’t match or when the decoding fails.

pub fn pre_runtime_try_to<T>(&self, id: &[u8; 4]) -> Option<T>
where T: Decode,

Try to match this to a Self::PreRuntime, check id matches and decode it.

Returns None if this isn’t a pre-runtime item, the id doesn’t match or when the decoding fails.

Trait Implementations

§

impl CheckEqual for DigestItem

§

fn check_equal(&self, other: &DigestItem)

Perform the equality check.
§

impl Clone for DigestItem

§

fn clone(&self) -> DigestItem

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for DigestItem

§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Decode for DigestItem

§

fn decode<I>(input: &mut I) -> Result<DigestItem, Error>
where I: Input,

Attempt to deserialise the value from input.
§

fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
where I: Input,

Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
§

impl<'a> Deserialize<'a> for DigestItem

§

fn deserialize<D>(de: D) -> Result<DigestItem, <D as Deserializer<'a>>::Error>
where D: Deserializer<'a>,

Deserialize this value from the given Serde deserializer. Read more
§

impl Encode for DigestItem

§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
§

fn encode_to<T>(&self, dest: &mut T)
where T: Output + ?Sized,

Convert self to a slice and append it to the destination.
§

fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
§

impl PartialEq for DigestItem

§

fn eq(&self, other: &DigestItem) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Serialize for DigestItem

§

fn serialize<S>( &self, seq: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl TypeInfo for DigestItem

§

type Identity = DigestItem

The type identifying for which type info is provided. Read more
§

fn type_info() -> Type

Returns the static type identifier for Self.
§

impl DecodeWithMemTracking for DigestItem

§

impl EncodeLike for DigestItem

§

impl Eq for DigestItem

§

impl StructuralPartialEq for DigestItem