pub struct VersionStore { /* private fields */ }Expand description
Content-addressable version store with branch and lineage support.
Implementations§
Source§impl VersionStore
impl VersionStore
Sourcepub fn new(max_output_tokens: usize) -> Self
pub fn new(max_output_tokens: usize) -> Self
Creates a new store with the given maximum output token limit per version.
Sourcepub fn store(&mut self, version: OutputVersion) -> Result<String, DiffError>
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.
Sourcepub fn get(&self, id: &str) -> Result<&OutputVersion, DiffError>
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.
Sourcepub fn get_by_address(&self, addr: &str) -> Option<&OutputVersion>
pub fn get_by_address(&self, addr: &str) -> Option<&OutputVersion>
Retrieves a version by its content address, if present.
Sourcepub fn set_branch(
&mut self,
branch: impl Into<String>,
version_id: impl Into<String>,
) -> Result<(), DiffError>
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.
Sourcepub fn branch_head(&self, branch: &str) -> Result<&OutputVersion, DiffError>
pub fn branch_head(&self, branch: &str) -> Result<&OutputVersion, DiffError>
Returns the head version of a named branch.
§Errors
DiffError::BranchNotFoundif the branch does not exist.DiffError::VersionNotFoundif the branch head ID is stale.
Sourcepub fn diff_versions(
&self,
from_id: &str,
to_id: &str,
) -> Result<TextDiff, DiffError>
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.
Sourcepub fn rollback(
&self,
version_id: &str,
) -> Result<Option<&OutputVersion>, DiffError>
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.
Sourcepub fn lineage(
&self,
version_id: &str,
) -> Result<Vec<&OutputVersion>, DiffError>
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.
Sourcepub fn version_count(&self) -> usize
pub fn version_count(&self) -> usize
Returns the total number of stored versions.