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
impl RyoStorage
Sourcepub const SESSIONS_DIR: &'static str = "sessions"
pub const SESSIONS_DIR: &'static str = "sessions"
Sessions subdirectory name.
Sourcepub const PROJECTS_DIR: &'static str = "projects"
pub const PROJECTS_DIR: &'static str = "projects"
Projects subdirectory name.
Sourcepub const INDEX_FILE: &'static str = "index.json"
pub const INDEX_FILE: &'static str = "index.json"
Session index file name.
Sourcepub const PROJECT_INDEX_FILE: &'static str = "projects.json"
pub const PROJECT_INDEX_FILE: &'static str = "projects.json"
Project index file name.
Sourcepub fn global() -> StorageResult<Self>
pub fn global() -> StorageResult<Self>
Create a new storage manager at the default location (~/.ryo/).
Sourcepub fn new(root: PathBuf) -> StorageResult<Self>
pub fn new(root: PathBuf) -> StorageResult<Self>
Create a new storage manager at a custom location.
Sourcepub fn with_format(self, format: Format) -> Self
pub fn with_format(self, format: Format) -> Self
Set the serialization format.
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if storage is initialized (directories exist).
Sourcepub fn init(&self) -> StorageResult<()>
pub fn init(&self) -> StorageResult<()>
Initialize storage directories.
Sourcepub fn ensure_init(&self) -> StorageResult<()>
pub fn ensure_init(&self) -> StorageResult<()>
Ensure storage is initialized, creating directories if needed.
Sourcepub fn dump(&mut self, log: &TxLog) -> StorageResult<String>
pub fn dump(&mut self, log: &TxLog) -> StorageResult<String>
Dump a session log to storage.
Returns the session ID.
Sourcepub fn load(&self, session_id: &str) -> StorageResult<TxLog>
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.
Sourcepub fn delete(&mut self, session_id: &str) -> StorageResult<()>
pub fn delete(&mut self, session_id: &str) -> StorageResult<()>
Delete a session (in any format).
Sourcepub fn index(&mut self) -> StorageResult<&SessionIndex>
pub fn index(&mut self) -> StorageResult<&SessionIndex>
Get the session index.
Sourcepub fn list_sessions(&mut self) -> StorageResult<Vec<&SessionMeta>>
pub fn list_sessions(&mut self) -> StorageResult<Vec<&SessionMeta>>
List all sessions.
Sourcepub fn sessions_for_project(
&mut self,
project_path: &Path,
) -> StorageResult<Vec<&SessionMeta>>
pub fn sessions_for_project( &mut self, project_path: &Path, ) -> StorageResult<Vec<&SessionMeta>>
Find sessions by project path.
Sourcepub fn latest_session(&mut self) -> StorageResult<Option<&SessionMeta>>
pub fn latest_session(&mut self) -> StorageResult<Option<&SessionMeta>>
Get the most recent session.
Sourcepub fn latest_for_project(
&mut self,
project_path: &Path,
) -> StorageResult<Option<&SessionMeta>>
pub fn latest_for_project( &mut self, project_path: &Path, ) -> StorageResult<Option<&SessionMeta>>
Get the most recent session for a project.
Sourcepub fn cleanup(&mut self, keep_per_project: usize) -> StorageResult<usize>
pub fn cleanup(&mut self, keep_per_project: usize) -> StorageResult<usize>
Clean up old sessions (keep last N per project).
Sourcepub fn storage_size(&self) -> StorageResult<u64>
pub fn storage_size(&self) -> StorageResult<u64>
Get total storage size in bytes.
Sourcepub fn project_index(&mut self) -> StorageResult<&ProjectIndex>
pub fn project_index(&mut self) -> StorageResult<&ProjectIndex>
Get the project index.
Sourcepub fn register_project(&mut self, meta: ProjectMeta) -> StorageResult<String>
pub fn register_project(&mut self, meta: ProjectMeta) -> StorageResult<String>
Register a project in the index.
Sourcepub fn unregister_project(
&mut self,
project_id: &str,
) -> StorageResult<Option<ProjectMeta>>
pub fn unregister_project( &mut self, project_id: &str, ) -> StorageResult<Option<ProjectMeta>>
Unregister a project from the index.
Sourcepub fn get_project(
&mut self,
project_id: &str,
) -> StorageResult<Option<&ProjectMeta>>
pub fn get_project( &mut self, project_id: &str, ) -> StorageResult<Option<&ProjectMeta>>
Get a project by ID.
Sourcepub fn get_project_by_path(
&mut self,
path: &Path,
) -> StorageResult<Option<&ProjectMeta>>
pub fn get_project_by_path( &mut self, path: &Path, ) -> StorageResult<Option<&ProjectMeta>>
Get a project by path.
Sourcepub fn get_project_by_path_mut(
&mut self,
path: &Path,
) -> StorageResult<Option<&mut ProjectMeta>>
pub fn get_project_by_path_mut( &mut self, path: &Path, ) -> StorageResult<Option<&mut ProjectMeta>>
Get a mutable project by path.
Sourcepub fn save_projects(&self) -> StorageResult<()>
pub fn save_projects(&self) -> StorageResult<()>
Save the project index (public for external updates).
Sourcepub fn search_projects_by_name(
&mut self,
pattern: &str,
) -> StorageResult<Vec<&ProjectMeta>>
pub fn search_projects_by_name( &mut self, pattern: &str, ) -> StorageResult<Vec<&ProjectMeta>>
Search projects by name pattern.
Sourcepub fn is_project_registered(&mut self, path: &Path) -> StorageResult<bool>
pub fn is_project_registered(&mut self, path: &Path) -> StorageResult<bool>
Check if a project path is already registered.
Sourcepub fn list_projects(&mut self) -> StorageResult<Vec<&ProjectMeta>>
pub fn list_projects(&mut self) -> StorageResult<Vec<&ProjectMeta>>
List all registered projects.
Sourcepub fn touch_project(&mut self, project_id: &str) -> StorageResult<()>
pub fn touch_project(&mut self, project_id: &str) -> StorageResult<()>
Touch a project (update last accessed time).
Sourcepub fn project_stats(&mut self) -> StorageResult<(usize, usize, usize)>
pub fn project_stats(&mut self) -> StorageResult<(usize, usize, usize)>
Get project statistics.
Sourcepub fn cleanup_dead_servers(&mut self) -> StorageResult<usize>
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.
Sourcepub fn list_projects_with_cleanup(
&mut self,
cleanup: bool,
) -> StorageResult<Vec<&ProjectMeta>>
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.
Sourcepub fn save_graph_cache(
&self,
project_hash: &str,
data: &[u8],
) -> StorageResult<PathBuf>
pub fn save_graph_cache( &self, project_hash: &str, data: &[u8], ) -> StorageResult<PathBuf>
Save a CodeGraph cache.
Returns the cache file path.
Sourcepub fn load_graph_cache(
&self,
project_hash: &str,
) -> StorageResult<Option<Vec<u8>>>
pub fn load_graph_cache( &self, project_hash: &str, ) -> StorageResult<Option<Vec<u8>>>
Load a CodeGraph cache.
Returns None if cache doesn’t exist.
Sourcepub fn delete_graph_cache(&self, project_hash: &str) -> StorageResult<()>
pub fn delete_graph_cache(&self, project_hash: &str) -> StorageResult<()>
Delete a CodeGraph cache.
Sourcepub fn list_graph_caches(&self) -> StorageResult<Vec<String>>
pub fn list_graph_caches(&self) -> StorageResult<Vec<String>>
List all cached project hashes.
Sourcepub fn cache_size(&self) -> StorageResult<u64>
pub fn cache_size(&self) -> StorageResult<u64>
Get cache storage size in bytes.
Sourcepub fn clear_graph_caches(&self) -> StorageResult<usize>
pub fn clear_graph_caches(&self) -> StorageResult<usize>
Clear all graph caches.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RyoStorage
impl RefUnwindSafe for RyoStorage
impl Send for RyoStorage
impl Sync for RyoStorage
impl Unpin for RyoStorage
impl UnsafeUnpin for RyoStorage
impl UnwindSafe for RyoStorage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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