Skip to main content

Project

Struct Project 

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

A project (directory containing session JSONL files)

Implementations§

Source§

impl Project

Source

pub fn new(id: ProjectId, storage_dir: PathBuf) -> Project

Create a new project reference

Source

pub fn load(storage_dir: &Path) -> Result<Project, Error>

Load project from storage directory

§Errors

Returns error if the directory does not exist, is not a directory, has an invalid or non-UTF-8 name, or if the encoded path cannot be decoded.

Source

pub fn id(&self) -> &ProjectId

Get project ID

Source

pub fn storage_dir(&self) -> &Path

Get storage directory path

Source

pub fn sessions(&self) -> Result<Vec<Session>, Error>

List all sessions in this project

§Errors

Returns error if the project directory cannot be read.

Source

pub fn has_sessions(&self) -> Result<bool, Error>

Check if project has any sessions

§Errors

Returns error if the project directory cannot be read.

Source

pub fn count_sessions(&self) -> Result<usize, Error>

Count sessions without loading them

§Errors

Returns error if the project directory cannot be read.

Source

pub fn count_sessions_split(&self) -> Result<(usize, usize), Error>

Count sessions by type using filename inspection only — no JSONL parsing.

Returns (main_sessions, agent_sessions). Agent sessions are identified by the agent- filename prefix; all other sessions are main sessions.

§Performance

O(N) directory listing only. Suitable for status/stats commands that need session counts without entry-level detail.

§Errors

Returns error if the project directory cannot be read.

Source

pub fn all_sessions(&self) -> Result<Vec<Session>, Error>

List all sessions including agent sessions

§Errors

Returns error if the project directory cannot be read.

Source

pub fn project_stats(&self) -> Result<ProjectStats, Error>

Compute project statistics

Aggregates statistics from all sessions (main and agent) in this project.

§Errors

Returns error if the project directory cannot be read or if a session file cannot be parsed.

Source

pub fn sessions_filtered( &mut self, filter: &SessionFilter, ) -> Result<Vec<Session>, Error>

List sessions matching filter

§Filtering Logic

Returns only sessions that match ALL filter conditions (AND logic):

  • agent_only: Filter by agent/main session type
  • min_entries: Minimum entry count
  • session_id_substring: Session ID substring match (case-insensitive)
§Examples
use claude_storage_core::{ Storage, SessionFilter };

let storage = Storage::new().unwrap();
let mut project = storage.list_projects().unwrap().into_iter().next().unwrap();

// Filter for agent sessions with 10+ entries
let filter = SessionFilter
{
  agent_only : Some( true ),
  min_entries : Some( 10 ),
  session_id_substring : None,
};

let sessions = project.sessions_filtered( &filter ).unwrap();
§Errors

Returns error if the project directory cannot be read or if session filtering fails (e.g., cannot read a session file for entry count).

Source

pub fn matches_filter(&self, filter: &ProjectFilter) -> Result<bool, Error>

Check if project matches filter

§Filtering Logic

All filter conditions must match (AND logic):

  • path_substring: Path substring match (case-insensitive)
  • min_entries: Minimum total entries across all sessions
  • min_sessions: Minimum session count
§Examples
use claude_storage_core::{ Storage, ProjectFilter };

let storage = Storage::new().unwrap();
let project = storage.list_projects().unwrap().into_iter().next().unwrap();

let filter = ProjectFilter
{
  path_substring : Some( "myproject".to_string() ),
  min_entries : None,
  min_sessions : Some( 5 ),
};

assert!( project.matches_filter( &filter ).unwrap() );
§Errors

Returns error if reading session counts or project statistics fails.

Trait Implementations§

Source§

impl Debug for Project

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

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<C, E> EntryToVal<C> for E
where C: Collection<Entry = E>,

Source§

type Val = <C as Collection>::Val

The type of values stored in the collection. This might be distinct from Entry in complex collections. For example, in a HashMap, while Entry might be a ( key, value ) tuple, Val might only be the value part.
Source§

fn entry_to_val(self) -> <E as EntryToVal<C>>::Val

Converts an entry into a value representation specific to the type of collection. This conversion is crucial for handling operations on entries, especially when they need to be treated or accessed as individual values, such as retrieving the value part from a key-value pair in a hash map.
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.
Source§

impl<C, Val> ValToEntry<C> for Val
where C: CollectionValToEntry<Val>,

Source§

fn val_to_entry(self) -> <C as CollectionValToEntry<Val>>::Entry

Invokes the val_to_entry function of the CollectionValToEntry trait to convert the value to an entry.

Source§

type Entry = <C as CollectionValToEntry<Val>>::Entry

Represents the type of entry that corresponds to the value within the collection. Type Entry is defined by the Collection trait.