pub struct FileStore { /* private fields */ }Expand description
JSON file-based persistent Store
Implementations§
Source§impl FileStore
impl FileStore
Sourcepub fn new(path: impl AsRef<Path>) -> Result<FileStore, ReactError>
pub fn new(path: impl AsRef<Path>) -> Result<FileStore, ReactError>
Open or create the Store file, auto-create parent directories
Sourcepub async fn put_batch(
&self,
entries: impl IntoIterator<Item = (Vec<&str>, &str, Value)>,
) -> Result<(), ReactError>
pub async fn put_batch( &self, entries: impl IntoIterator<Item = (Vec<&str>, &str, Value)>, ) -> Result<(), ReactError>
Batch write: write multiple records to memory then flush to disk once, reducing IO overhead.
Sourcepub async fn flush_public(&self) -> Result<(), ReactError>
pub async fn flush_public(&self) -> Result<(), ReactError>
Flush in-memory data to disk.
Trait Implementations§
Source§impl Store for FileStore
impl Store for FileStore
Source§fn put<'a>(
&'a self,
namespace: &'a [&'a str],
key: &'a str,
value: Value,
) -> Pin<Box<dyn Future<Output = Result<(), ReactError>> + Send + 'a>>
fn put<'a>( &'a self, namespace: &'a [&'a str], key: &'a str, value: Value, ) -> Pin<Box<dyn Future<Output = Result<(), ReactError>> + Send + 'a>>
Write or update a record (upsert)
Source§fn get<'a>(
&'a self,
namespace: &'a [&'a str],
key: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Option<StoreItem>, ReactError>> + Send + 'a>>
fn get<'a>( &'a self, namespace: &'a [&'a str], key: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<StoreItem>, ReactError>> + Send + 'a>>
Exact fetch by key
Source§fn search<'a>(
&'a self,
namespace: &'a [&'a str],
query: &'a str,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<StoreItem>, ReactError>> + Send + 'a>>
fn search<'a>( &'a self, namespace: &'a [&'a str], query: &'a str, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<StoreItem>, ReactError>> + Send + 'a>>
Keyword search, returns at most
limit items (sorted by relevance)Source§fn delete<'a>(
&'a self,
namespace: &'a [&'a str],
key: &'a str,
) -> Pin<Box<dyn Future<Output = Result<bool, ReactError>> + Send + 'a>>
fn delete<'a>( &'a self, namespace: &'a [&'a str], key: &'a str, ) -> Pin<Box<dyn Future<Output = Result<bool, ReactError>> + Send + 'a>>
Delete the specified key, returns whether it existed and was deleted
Source§fn list_namespaces<'a>(
&'a self,
prefix: Option<&'a [&'a str]>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<String>>, ReactError>> + Send + 'a>>
fn list_namespaces<'a>( &'a self, prefix: Option<&'a [&'a str]>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<String>>, ReactError>> + Send + 'a>>
List all namespaces matching the given
prefixSource§fn list<'a>(
&'a self,
namespace: &'a [&'a str],
) -> Pin<Box<dyn Future<Output = Result<Vec<StoreItem>, ReactError>> + Send + 'a>>
fn list<'a>( &'a self, namespace: &'a [&'a str], ) -> Pin<Box<dyn Future<Output = Result<Vec<StoreItem>, ReactError>> + Send + 'a>>
List all entries in the namespace (no keyword filter, no pagination limit).
Source§fn search_with<'a>(
&'a self,
namespace: &'a [&'a str],
query: SearchQuery<'a>,
) -> Pin<Box<dyn Future<Output = Result<Vec<StoreItem>, ReactError>> + Send + 'a>>
fn search_with<'a>( &'a self, namespace: &'a [&'a str], query: SearchQuery<'a>, ) -> Pin<Box<dyn Future<Output = Result<Vec<StoreItem>, ReactError>> + Send + 'a>>
Unified search entry point. Read more
Auto Trait Implementations§
impl !Freeze for FileStore
impl !RefUnwindSafe for FileStore
impl Send for FileStore
impl Sync for FileStore
impl Unpin for FileStore
impl UnsafeUnpin for FileStore
impl !UnwindSafe for FileStore
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
Mutably borrows from an owned value. Read more
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
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 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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request