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:
| Generation | Inherited | Local |
|---|---|---|
| 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§
Required Methods§
Sourcefn accrete(&self) -> Self
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.
Sourcefn add_to_local(&mut self, item: Self::Item) -> [u8; 32]
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.
Sourcefn exists_in_local(&self, key: &[u8; 32]) -> bool
fn exists_in_local(&self, key: &[u8; 32]) -> bool
Returns true if the given key exists in the current
local generation only.
Sourcefn exists_in_inherited(&self, key: &[u8; 32]) -> bool
fn exists_in_inherited(&self, key: &[u8; 32]) -> bool
Returns true if the given key exists in inherited
generations only.
Sourcefn remove_from_local(&mut self, key: &[u8; 32])
fn remove_from_local(&mut self, key: &[u8; 32])
Removes a key from the current local generation.
Sourcefn remove_from_inherited(&mut self, key: &[u8; 32])
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§
Sourcefn make_key(item: &Self::Item) -> [u8; 32]
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.