Trait Accrete

Source
pub trait Accrete: Clone {
    type Item: Probe;

    // Required methods
    fn accrete(&self) -> Self;
    fn inherited(&self) -> Vec<[u8; 32]>;
    fn local(&self) -> Vec<[u8; 32]>;
    fn add_to_local(&mut self, item: Self::Item) -> [u8; 32];
    fn exists_in_local(&self, key: &[u8; 32]) -> bool;
    fn exists_in_inherited(&self, key: &[u8; 32]) -> bool;
    fn remove_from_local(&mut self, key: &[u8; 32]);
    fn remove_from_inherited(&mut self, key: &[u8; 32]);

    // Provided method
    fn make_key(item: &Self::Item) -> [u8; 32] { ... }
}
Expand description

A trait for structures that grow by preserving previous state while creating fresh local generations.

Accrete stores and propagates deterministic item keys, not the full item payload itself.

The actual payload may live elsewhere (for example: key -> value storage), while this structure tracks only membership and historical propagation of stable keys.

Calling accrete() creates a new generation where:

  • current local item keys are promoted into inherited history
  • the returned value begins with fresh local state

Example flow:

GenerationInheritedLocal
A[][a, b]
B[a, b][]
B[a, b][c, d]
C[a, b, c, d][]

where a, b, c, and d represent deterministic item key hashes ([u8; 32]), not full values.

This allows persistent, layered growth where older generations remain preserved while new values are added independently.

§Note

Always prefer working with the most recent generation, since it contains the complete inherited state of all previous generations.

Older generations may be retained for history, snapshots, or audit purposes, but they should not be used for active logic without first consulting the latest generation to confirm whether that state still exists, has changed, or has been removed.

Required Associated Types§

Source

type Item: Probe

The payload type used to derive deterministic keys.

The payload itself is not stored inside the accreted structure. Only its stable deterministic key hash is tracked.

Required Methods§

Source

fn accrete(&self) -> Self

Creates the next generation from the current instance.

The current local key set becomes inherited history, and the returned value starts a fresh local generation.

Source

fn inherited(&self) -> Vec<[u8; 32]>

Returns keys inherited from previous generations.

Source

fn local(&self) -> Vec<[u8; 32]>

Returns keys belonging only to the current generation.

Source

fn add_to_local(&mut self, item: Self::Item) -> [u8; 32]

Inserts an item’s deterministic key into the current local generation.

Returns the stable key used for future reference.

Source

fn exists_in_local(&self, key: &[u8; 32]) -> bool

Returns true if the given key exists in the current local generation only.

Source

fn exists_in_inherited(&self, key: &[u8; 32]) -> bool

Returns true if the given key exists in inherited generations only.

Source

fn remove_from_local(&mut self, key: &[u8; 32])

Removes a key from the current local generation.

Source

fn remove_from_inherited(&mut self, key: &[u8; 32])

Removes a key from inherited generations.

This should be used carefully since inherited state affects descendant visibility.

Provided Methods§

Source

fn make_key(item: &Self::Item) -> [u8; 32]

Creates a deterministic key for an item.

This key is what gets stored, inherited, and removed across generations.

This should be stable across executions so the same item always resolves to the same key.

Typical implementations use:

  • SCALE encoding + hash (blake2_256)
  • canonical identifiers
  • domain-specific unique references

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§