pub struct Journal {
pub entries: Vec<JournalEntry>,
pub leaf_id: Option<String>,
}Expand description
Append-only journal with a leafId cursor. The tree projection is
derived root→leaf; moving leaf_id branches without rewriting history.
Fields§
§entries: Vec<JournalEntry>§leaf_id: Option<String>Active position. None before the header is appended.
Implementations§
Source§impl Journal
impl Journal
pub fn new() -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn append(&mut self, kind: impl Into<String>, payload: Value) -> String
pub fn append(&mut self, kind: impl Into<String>, payload: Value) -> String
Append a new entry as a child of the current leaf. Returns the new id.
Sourcepub fn branch_to(&mut self, target: &str) -> bool
pub fn branch_to(&mut self, target: &str) -> bool
Branch: move leaf_id to an existing ancestor without rewriting.
Returns false when target is not found.
Sourcepub fn active_path(&self) -> Vec<&JournalEntry>
pub fn active_path(&self) -> Vec<&JournalEntry>
Project the active path root→leaf as a slice of entries in order.
Sourcepub fn get(&self, id: &str) -> Option<&JournalEntry>
pub fn get(&self, id: &str) -> Option<&JournalEntry>
Find entry by id.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Journal
impl<'de> Deserialize<'de> for Journal
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Journal
Auto Trait Implementations§
impl Freeze for Journal
impl RefUnwindSafe for Journal
impl Send for Journal
impl Sync for Journal
impl Unpin for Journal
impl UnsafeUnpin for Journal
impl UnwindSafe for Journal
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more