Skip to main content

Event

Trait Event 

Source
pub trait Event:
    Sealed
    + Debug
    + Serialize
    + DeserializeOwned
    + 'static {
    const TYPE_CODE: TypeCode;
    const SCHEMA_VERSION: u32;

    // Provided methods
    fn canonical_bytes(&self) -> Vec<u8> 
       where Self: Sized { ... }
    fn from_bytes(
        version: u32,
        bytes: &[u8],
    ) -> Result<Box<Self>, DeserializeError>
       where Self: Sized { ... }
    fn approx_size(&self) -> usize
       where Self: Sized { ... }
}
Expand description

Event — derive-only via #[derive(arkhe_macros::ArkheEvent)]. Same postcard-default shape as Component; user types must additionally #[derive(Debug, serde::Serialize, serde::Deserialize)].

Required Associated Constants§

Source

const TYPE_CODE: TypeCode

Stable dispatch identifier. Set via #[arkhe(type_code = N, ...)].

Source

const SCHEMA_VERSION: u32

Version tag for canonical bytes.

Provided Methods§

Source

fn canonical_bytes(&self) -> Vec<u8>
where Self: Sized,

Postcard-canonical byte encoding.

Source

fn from_bytes(version: u32, bytes: &[u8]) -> Result<Box<Self>, DeserializeError>
where Self: Sized,

Inverse of canonical_bytes.

Source

fn approx_size(&self) -> usize
where Self: Sized,

Approximate byte size — defaults to encoded length.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§