Skip to main content

SeedTree

Struct SeedTree 

Source
pub struct SeedTree { /* private fields */ }
Expand description

Hierarchical, domain-keyed seed derivation.

SeedTree derives independent sub-seeds for each named subsystem using FNV-1a hashing. The critical invariant: derive("fs") always returns the same sub-seed regardless of what other domains are (or are not) derived.

let tree = SeedTree::new(42u64.into());
let fs_seed = tree.derive("fs");
let net_seed = tree.derive("net");

// Different domains produce different seeds
assert_ne!(fs_seed.to_u64(), net_seed.to_u64());

// Same domain + same master seed = same sub-seed (deterministic)
let tree2 = SeedTree::new(42u64.into());
assert_eq!(tree.derive("fs"), tree2.derive("fs"));

Implementations§

Source§

impl SeedTree

Source

pub const fn new(master: VortexSeed) -> Self

Create a new seed tree from a master seed.

Source

pub fn derive(&self, domain: &str) -> VortexSeed

Derive a sub-seed for a named domain.

Uses FNV-1a to mix the master seed bytes with the domain string. The result is a new VortexSeed that is:

  • Deterministic: same master + same domain = same output, always.
  • Independent: changing the domain name changes the output completely.
Source

pub fn subtree(&self, domain: &str) -> SeedTree

Derive a sub-seed for a named domain, then create a child SeedTree from it. Useful for hierarchical subsystems.

let root = SeedTree::new(42u64.into());
let fs_tree = root.subtree("fs");
let wal_seed = fs_tree.derive("wal");
let data_seed = fs_tree.derive("data");
Source

pub const fn master(&self) -> VortexSeed

Get the master seed.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.