Skip to main content

Crate arkhe_macros

Crate arkhe_macros 

Source
Expand description

Derive macros for ArkheKernel.

Three derives, one shared shape:

  • #[derive(ArkheAction)] — emits Sealed + ActionDeriv. The user supplies impl ActionCompute for T { fn compute ... }; the kernel-side blanket impl<T: ActionDeriv + ActionCompute> Action for T provides the postcard-canonical canonical_bytes/from_bytes/approx_size defaults.
  • #[derive(ArkheComponent)] — emits Sealed + Component. No user method to implement; the trait’s default methods (postcard) handle the data round trip.
  • #[derive(ArkheEvent)] — emits Sealed + Event, same shape as Component. The user type must additionally derive Debug plus serde::{Serialize, Deserialize}.

Every derive expects #[arkhe(type_code = N, schema_version = M)]. schema_version defaults to 1 when omitted; type_code is mandatory.

use arkhe_kernel::{ArkheComponent, ArkheEvent};
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, ArkheComponent)]
#[arkhe(type_code = 5001, schema_version = 1)]
struct CounterComponent { value: u64 }

#[derive(Debug, Serialize, Deserialize, ArkheEvent)]
#[arkhe(type_code = 8001)]
struct PostCreatedEvent { author: u64, body: String }

Derive Macros§

ArkheAction
Derive Sealed + ActionDeriv for a domain action. Pair with impl ActionCompute for ... to satisfy the kernel Action blanket.
ArkheComponent
Derive Sealed + Component. Default trait methods (postcard) cover canonical_bytes / from_bytes / approx_size — no user method required beyond serde::{Serialize, Deserialize} derives.
ArkheEvent
Derive Sealed + Event. Same shape as ArkheComponent; the user type must additionally derive Debug plus serde.