Skip to main content

VersionStore

Struct VersionStore 

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

Content-addressable version store with branch and lineage support.

Implementations§

Source§

impl VersionStore

Source

pub fn new(max_output_tokens: usize) -> Self

Creates a new store with the given maximum output token limit per version.

Source

pub fn store(&mut self, version: OutputVersion) -> Result<String, DiffError>

Stores a version, returning its ID.

§Errors

Returns DiffError::OutputTooLarge if the content exceeds the token limit.

Source

pub fn get(&self, id: &str) -> Result<&OutputVersion, DiffError>

Retrieves a version by ID.

§Errors

Returns DiffError::VersionNotFound if no version with that ID exists.

Source

pub fn get_by_address(&self, addr: &str) -> Option<&OutputVersion>

Retrieves a version by its content address, if present.

Source

pub fn set_branch( &mut self, branch: impl Into<String>, version_id: impl Into<String>, ) -> Result<(), DiffError>

Points a named branch at a version.

§Errors

Returns DiffError::VersionNotFound if the version ID does not exist.

Source

pub fn branch_head(&self, branch: &str) -> Result<&OutputVersion, DiffError>

Returns the head version of a named branch.

§Errors
Source

pub fn diff_versions( &self, from_id: &str, to_id: &str, ) -> Result<TextDiff, DiffError>

Computes a text diff between two stored versions.

§Errors

Returns DiffError::VersionNotFound if either ID is missing.

Source

pub fn rollback( &self, version_id: &str, ) -> Result<Option<&OutputVersion>, DiffError>

Returns the parent version of the given version, or None if it is a root.

§Errors

Returns DiffError::VersionNotFound if the version ID or its parent ID is missing.

Source

pub fn lineage( &self, version_id: &str, ) -> Result<Vec<&OutputVersion>, DiffError>

Returns the full ancestor chain starting from version_id, oldest last.

§Errors

Returns DiffError::VersionNotFound if any version in the chain is missing.

Source

pub fn version_count(&self) -> usize

Returns the total number of stored versions.

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.