Skip to main content

RyoStorage

Struct RyoStorage 

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

Global RYO storage manager.

Provides high-level API for:

  • Dumping session logs
  • Loading past sessions
  • Querying session history
  • Managing imported projects
  • Managing storage lifecycle

Implementations§

Source§

impl RyoStorage

Source

pub const DIR_NAME: &'static str = ".ryo"

Default RYO directory name.

Source

pub const SESSIONS_DIR: &'static str = "sessions"

Sessions subdirectory name.

Source

pub const PROJECTS_DIR: &'static str = "projects"

Projects subdirectory name.

Source

pub const INDEX_FILE: &'static str = "index.json"

Session index file name.

Source

pub const PROJECT_INDEX_FILE: &'static str = "projects.json"

Project index file name.

Source

pub const CACHE_DIR: &'static str = "cache"

Cache subdirectory name.

Source

pub fn global() -> StorageResult<Self>

Create a new storage manager at the default location (~/.ryo/).

Source

pub fn new(root: PathBuf) -> StorageResult<Self>

Create a new storage manager at a custom location.

Source

pub fn with_format(self, format: Format) -> Self

Set the serialization format.

Source

pub fn root(&self) -> &Path

Get the root directory path.

Source

pub fn is_initialized(&self) -> bool

Check if storage is initialized (directories exist).

Source

pub fn init(&self) -> StorageResult<()>

Initialize storage directories.

Source

pub fn ensure_init(&self) -> StorageResult<()>

Ensure storage is initialized, creating directories if needed.

Source

pub fn dump(&mut self, log: &TxLog) -> StorageResult<String>

Dump a session log to storage.

Returns the session ID.

Source

pub fn load(&self, session_id: &str) -> StorageResult<TxLog>

Load a session log by ID.

This method automatically detects the file format by trying all known formats.

Source

pub fn exists(&self, session_id: &str) -> bool

Check if a session exists (in any format).

Source

pub fn delete(&mut self, session_id: &str) -> StorageResult<()>

Delete a session (in any format).

Source

pub fn index(&mut self) -> StorageResult<&SessionIndex>

Get the session index.

Source

pub fn list_sessions(&mut self) -> StorageResult<Vec<&SessionMeta>>

List all sessions.

Source

pub fn sessions_for_project( &mut self, project_path: &Path, ) -> StorageResult<Vec<&SessionMeta>>

Find sessions by project path.

Source

pub fn latest_session(&mut self) -> StorageResult<Option<&SessionMeta>>

Get the most recent session.

Source

pub fn latest_for_project( &mut self, project_path: &Path, ) -> StorageResult<Option<&SessionMeta>>

Get the most recent session for a project.

Source

pub fn cleanup(&mut self, keep_per_project: usize) -> StorageResult<usize>

Clean up old sessions (keep last N per project).

Source

pub fn storage_size(&self) -> StorageResult<u64>

Get total storage size in bytes.

Source

pub fn project_index(&mut self) -> StorageResult<&ProjectIndex>

Get the project index.

Source

pub fn register_project(&mut self, meta: ProjectMeta) -> StorageResult<String>

Register a project in the index.

Source

pub fn unregister_project( &mut self, project_id: &str, ) -> StorageResult<Option<ProjectMeta>>

Unregister a project from the index.

Source

pub fn get_project( &mut self, project_id: &str, ) -> StorageResult<Option<&ProjectMeta>>

Get a project by ID.

Source

pub fn get_project_by_path( &mut self, path: &Path, ) -> StorageResult<Option<&ProjectMeta>>

Get a project by path.

Source

pub fn get_project_by_path_mut( &mut self, path: &Path, ) -> StorageResult<Option<&mut ProjectMeta>>

Get a mutable project by path.

Source

pub fn save_projects(&self) -> StorageResult<()>

Save the project index (public for external updates).

Source

pub fn search_projects_by_name( &mut self, pattern: &str, ) -> StorageResult<Vec<&ProjectMeta>>

Search projects by name pattern.

Source

pub fn is_project_registered(&mut self, path: &Path) -> StorageResult<bool>

Check if a project path is already registered.

Source

pub fn list_projects(&mut self) -> StorageResult<Vec<&ProjectMeta>>

List all registered projects.

Source

pub fn touch_project(&mut self, project_id: &str) -> StorageResult<()>

Touch a project (update last accessed time).

Source

pub fn project_stats(&mut self) -> StorageResult<(usize, usize, usize)>

Get project statistics.

Source

pub fn cleanup_dead_servers(&mut self) -> StorageResult<usize>

Cleanup dead server PIDs from all projects.

Checks each project’s server_pid and clears it if the process is no longer running. Returns the number of projects that were cleaned up.

Source

pub fn list_projects_with_cleanup( &mut self, cleanup: bool, ) -> StorageResult<Vec<&ProjectMeta>>

List all registered projects, with optional dead server cleanup.

If cleanup is true, dead server PIDs are automatically cleared before listing.

Source

pub fn cache_dir(&self) -> PathBuf

Get the cache directory path.

Source

pub fn save_graph_cache( &self, project_hash: &str, data: &[u8], ) -> StorageResult<PathBuf>

Save a CodeGraph cache.

Returns the cache file path.

Source

pub fn load_graph_cache( &self, project_hash: &str, ) -> StorageResult<Option<Vec<u8>>>

Load a CodeGraph cache.

Returns None if cache doesn’t exist.

Source

pub fn delete_graph_cache(&self, project_hash: &str) -> StorageResult<()>

Delete a CodeGraph cache.

Source

pub fn list_graph_caches(&self) -> StorageResult<Vec<String>>

List all cached project hashes.

Source

pub fn cache_size(&self) -> StorageResult<u64>

Get cache storage size in bytes.

Source

pub fn clear_graph_caches(&self) -> StorageResult<usize>

Clear all graph caches.

Trait Implementations§

Source§

impl Debug for RyoStorage

Source§

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

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<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.