Skip to main content

Ledger

Struct Ledger 

Source
pub struct Ledger {
    pub paths: EddaPaths,
    /* private fields */
}
Expand description

The append-only event ledger (SQLite backend).

Fields§

§paths: EddaPaths

Implementations§

Source§

impl Ledger

Source

pub fn open(repo_root: impl Into<PathBuf>) -> Result<Self>

Open an existing workspace. Fails if .edda/ does not exist.

Source

pub fn open_or_init(repo_root: impl Into<PathBuf>) -> Result<Self>

Open a workspace, auto-initializing .edda/ if missing.

Use this for read-path consumers (e.g. edda watch) that should work without requiring the user to run edda init first.

This is a lightweight init — it only creates the ledger directory layout and SQLite DB. Config files (policy.yaml, actors.yaml) and bridge hooks are NOT created; those require edda init.

Source

pub fn ensure_initialized(repo_root: impl Into<PathBuf>) -> Result<()>

Ensure .edda/ and ledger exist, without returning a Ledger handle.

Use this when you only need the side effect (workspace creation) and will open the ledger separately later.

Source

pub fn open_path(repo_root: &Path) -> Result<Self>

Convenience: open from a Path ref (avoids Into ambiguity).

Source

pub fn head_branch(&self) -> Result<String>

Read the current HEAD branch name.

Source

pub fn set_head_branch(&self, name: &str) -> Result<()>

Write the HEAD branch name.

Source

pub fn append_event(&self, event: &Event) -> Result<()>

Append an event to the ledger. Append-only (CONTRACT LEDGER-02).

Source

pub fn last_event_hash(&self) -> Result<Option<String>>

Get the hash of the last event, or None if the ledger is empty.

Source

pub fn iter_events(&self) -> Result<Vec<Event>>

Read all events in the ledger.

Source

pub fn branches_json(&self) -> Result<Value>

Read branches.json content.

Source

pub fn set_branches_json(&self, value: &Value) -> Result<()>

Write branches.json content.

Source

pub fn active_decisions( &self, domain: Option<&str>, key_pattern: Option<&str>, ) -> Result<Vec<DecisionRow>>

Query active decisions, optionally filtered by domain or key pattern.

Source

pub fn decision_timeline(&self, key: &str) -> Result<Vec<DecisionRow>>

All decisions for a key (active + superseded), ordered by time.

Source

pub fn domain_timeline(&self, domain: &str) -> Result<Vec<DecisionRow>>

All decisions for a domain (active + superseded), ordered by time.

Source

pub fn list_domains(&self) -> Result<Vec<String>>

Distinct domain values from active decisions.

Source

pub fn find_active_decision( &self, branch: &str, key: &str, ) -> Result<Option<DecisionRow>>

Find the active decision for a specific key on a branch.

Auto Trait Implementations§

§

impl !Freeze for Ledger

§

impl !RefUnwindSafe for Ledger

§

impl Send for Ledger

§

impl !Sync for Ledger

§

impl Unpin for Ledger

§

impl UnsafeUnpin for Ledger

§

impl !UnwindSafe for Ledger

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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V