Skip to main content

Adapter

Trait Adapter 

Source
pub trait Adapter {
    // Required methods
    fn name(&self) -> &'static str;
    fn root(&self) -> Option<PathBuf>;
    fn discover(&self) -> Discovered;
    fn parse(&self, path: &Path) -> Result<Session>;

    // Provided methods
    fn store(&self) -> Option<Store> { ... }
    fn parse_key(&self, _key: &str) -> Result<Session> { ... }
    fn reconcile_scope(&self) -> Option<String> { ... }
}

Required Methods§

Source

fn name(&self) -> &'static str

Source

fn root(&self) -> Option<PathBuf>

Store root, e.g. ~/.claude/projects. May not exist on this machine.

Source

fn discover(&self) -> Discovered

All session files under the root, with a partial-walk flag the indexer uses to protect deletion reconciliation (see Discovered).

Source

fn parse(&self, path: &Path) -> Result<Session>

Parse one session file. Must never panic on malformed input; skip bad lines and return what could be read.

Provided Methods§

Source

fn store(&self) -> Option<Store>

A shared store (many sessions in one database) for tools that do not use one file per session. When Some, the indexer uses it instead of discover/parse. Default None = ordinary file-per-session adapter.

Source

fn parse_key(&self, _key: &str) -> Result<Session>

Parse one session out of a shared store by its key (from store().keys). Only called for adapters that return a Store.

Source

fn reconcile_scope(&self) -> Option<String>

Limit deletion reconciliation to part of this tool’s indexed rows. When Some(prefix), only indexed rows whose key starts with prefix are considered for archiving after this adapter runs. Use it when the adapter’s store holds only part of a tool’s sessions - for example several installations of the same tool sharing one tool name, each listing only its own keys - so that one installation’s sync cannot archive another’s rows. Default None = the adapter speaks for every row of its tool.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§