Skip to main content

AutoSaveLogger

Struct AutoSaveLogger 

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

Transaction logger with automatic persistence.

Wraps a TxLogger and automatically saves to ~/.ryo/ based on the configured TxLogMode.

§Example

use ryo_core::storage::{AutoSaveLogger, TxLogMode};

// Create with auto-save on commit
let logger = AutoSaveLogger::new("/my/project", 100, TxLogMode::OnCommit)?;

// Log as usual
logger.log_mutation("Rename", "foo -> bar", 5);

// Trigger save (e.g., called from CodingWorld::commit_changes)
logger.on_commit()?;

// Finish and get the log
let log = logger.finish()?;

Implementations§

Source§

impl AutoSaveLogger

Source

pub fn new( project_path: impl Into<PathBuf>, file_count: usize, mode: TxLogMode, ) -> StorageResult<Self>

Create a new auto-save logger.

Source

pub fn with_format( project_path: impl Into<PathBuf>, file_count: usize, mode: TxLogMode, format: Format, ) -> StorageResult<Self>

Create with a specific storage format.

Source

pub fn with_storage( project_path: impl Into<PathBuf>, file_count: usize, mode: TxLogMode, storage: RyoStorage, ) -> Self

Create with explicit storage (for testing or custom paths).

Source

pub fn format(&self) -> Format

Get the storage format.

Source

pub fn mode(&self) -> TxLogMode

Get the current mode.

Source

pub fn set_mode(&mut self, mode: TxLogMode)

Set the mode (can be changed at runtime).

Source

pub fn log(&self, action: TxAction)

Log an action.

Source

pub fn log_goal(&self, query: &str, intent_type: &str, confidence: f64)

Log a goal being set.

Source

pub fn log_mutation( &mut self, mutation_type: &str, target: &str, changes: usize, ) -> StorageResult<()>

Log a mutation being applied (legacy API - NOT replayable).

Note: For replayable logging, use record_mutation() instead. If mode is OnMutation, this will trigger a persist.

Source

pub fn record_mutation<M>( &mut self, mutation: &M, changes: usize, ) -> StorageResult<()>

Record a mutation with automatic serialization (REPLAYABLE).

This is the preferred method for logging mutations. If mode is OnMutation, this will trigger a persist.

Source

pub fn record_mutation_for_file<M>( &mut self, mutation: &M, changes: usize, file_path: impl AsRef<Path>, ) -> StorageResult<()>

Record a mutation with file path (REPLAYABLE).

If mode is OnMutation, this will trigger a persist.

Source

pub fn record_mutation_tracked<M>( &mut self, mutation: &M, changes: usize, file_path: impl AsRef<Path>, pre_state: StateRef, post_state: StateRef, ) -> StorageResult<()>

Record a mutation with full state tracking (REPLAYABLE + VERIFIABLE).

If mode is OnMutation, this will trigger a persist.

Source

pub fn log_mutation_with_data( &mut self, mutation_type: &str, target: &str, changes: usize, data: Value, ) -> StorageResult<()>

Log a mutation with data.

Source

pub fn log_mutation_batch( &mut self, mutations: Vec<MutationRecord>, total_changes: usize, ) -> StorageResult<()>

Log a batch of mutations.

Source

pub fn log_file_loaded(&self, path: &Path, size_bytes: usize)

Log file loaded.

Source

pub fn log_file_modified(&self, path: &Path, changes: usize)

Log file modified.

Source

pub fn log_file_written(&self, path: &Path)

Log file written.

Source

pub fn log_compile_check(&self, success: bool, errors: Vec<String>)

Log compile check result.

Source

pub fn checkpoint(&self, name: &str)

Create a checkpoint.

Source

pub fn log_undo(&self, target_id: u64)

Log an undo operation.

Source

pub fn log_redo(&self, target_id: u64)

Log a redo operation.

Source

pub fn log_custom(&self, name: &str, data: Value)

Log a custom action.

Source

pub fn on_commit(&mut self) -> StorageResult<()>

Called when commit_changes() is invoked.

If mode is OnCommit, this will trigger a persist.

Source

pub fn persist(&mut self) -> StorageResult<String>

Explicitly persist the current log to storage.

This can be called at any time, regardless of mode. Uses incremental save if session already has an ID.

Source

pub fn finish(self) -> StorageResult<(TxLog, Option<String>)>

Finish logging and persist the final log.

Returns the complete log and the session ID if persisted.

Source

pub fn finish_log(self) -> TxLog

Finish and return just the log (for compatibility).

Source

pub fn elapsed_ms(&self) -> u64

Get elapsed time since session start.

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.