pub struct MultiStorage { /* private fields */ }Expand description
Multi-backend storage abstraction that delegates to filesystem, in-memory, S3, or SQLite.
You pick one backend at construction via a storage-type string ("fs", "memory",
"aws", "sqlite", "rusqlite", or "local" on wasm32). All file operations are
then routed to that backend through the ObjectStore trait.
Implementations§
Source§impl MultiStorage
impl MultiStorage
Sourcepub fn clean_path(path: &str) -> String
pub fn clean_path(path: &str) -> String
Strip leading slashes from a path for non-filesystem backends. Returns "." if empty.
Sourcepub fn root(&self) -> Option<&Path>
pub fn root(&self) -> Option<&Path>
Returns the filesystem base directory, if this storage uses a filesystem backend.
Sourcepub fn default_new() -> Result<Self, ObjectStoreError>
pub fn default_new() -> Result<Self, ObjectStoreError>
Create a new MultiStorage with the default filesystem backend.
Sourcepub fn new(storage_type: String) -> Result<Self, ObjectStoreError>
pub fn new(storage_type: String) -> Result<Self, ObjectStoreError>
Create a new MultiStorage with the given backend type, rooted at the process CWD.
Sourcepub fn _new(
storage_type: String,
absolute_path: PathBuf,
) -> Result<Self, ObjectStoreError>
pub fn _new( storage_type: String, absolute_path: PathBuf, ) -> Result<Self, ObjectStoreError>
Create a new MultiStorage with an explicit base directory for filesystem storage.
Sourcepub fn save_file(
&self,
path: &str,
contents: &[u8],
) -> Result<(), ObjectStoreError>
pub fn save_file( &self, path: &str, contents: &[u8], ) -> Result<(), ObjectStoreError>
Write contents to path in all configured storage backends.
Sourcepub fn get_file(
&self,
path: &str,
preference: Option<StorageType>,
) -> Result<Vec<u8>, ObjectStoreError>
pub fn get_file( &self, path: &str, preference: Option<StorageType>, ) -> Result<Vec<u8>, ObjectStoreError>
Read a file from the preferred (or default) storage backend.
Sourcepub fn file_exists(
&self,
path: &str,
preference: Option<StorageType>,
) -> Result<bool, ObjectStoreError>
pub fn file_exists( &self, path: &str, preference: Option<StorageType>, ) -> Result<bool, ObjectStoreError>
Check whether a file exists in the preferred (or default) storage backend.
Sourcepub fn list(
&self,
prefix: &str,
preference: Option<StorageType>,
) -> Result<Vec<String>, ObjectStoreError>
pub fn list( &self, prefix: &str, preference: Option<StorageType>, ) -> Result<Vec<String>, ObjectStoreError>
List all files under prefix in the preferred (or default) storage backend.
Sourcepub fn rename_file(&self, from: &str, to: &str) -> Result<(), ObjectStoreError>
pub fn rename_file(&self, from: &str, to: &str) -> Result<(), ObjectStoreError>
Rename (move) a file across all configured storage backends.
Trait Implementations§
Source§impl Clone for MultiStorage
impl Clone for MultiStorage
Source§fn clone(&self) -> MultiStorage
fn clone(&self) -> MultiStorage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MultiStorage
impl Debug for MultiStorage
Source§impl StorageDocumentTraits for MultiStorage
impl StorageDocumentTraits for MultiStorage
fn store_document(&self, doc: &JACSDocument) -> Result<(), JacsError>
fn get_document(&self, key: &str) -> Result<JACSDocument, JacsError>
fn remove_document(&self, key: &str) -> Result<JACSDocument, JacsError>
fn list_documents(&self, prefix: &str) -> Result<Vec<String>, JacsError>
fn document_exists(&self, key: &str) -> Result<bool, JacsError>
fn get_documents_by_agent( &self, agent_id: &str, ) -> Result<Vec<String>, JacsError>
fn get_document_versions( &self, document_id: &str, ) -> Result<Vec<String>, JacsError>
fn get_latest_document( &self, document_id: &str, ) -> Result<JACSDocument, JacsError>
fn merge_documents( &self, _doc_id: &str, _v1: &str, _v2: &str, ) -> Result<JACSDocument, JacsError>
fn store_documents( &self, docs: Vec<JACSDocument>, ) -> Result<Vec<String>, Vec<JacsError>>
fn get_documents( &self, keys: Vec<String>, ) -> Result<Vec<JACSDocument>, Vec<JacsError>>
Auto Trait Implementations§
impl Freeze for MultiStorage
impl !RefUnwindSafe for MultiStorage
impl Send for MultiStorage
impl Sync for MultiStorage
impl Unpin for MultiStorage
impl UnsafeUnpin for MultiStorage
impl !UnwindSafe for MultiStorage
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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