pub struct FilesystemBackend {
base_path: PathBuf,
encryptor: Option<Encryptor>,
}Expand description
Filesystem-based persistence backend.
Fields§
§base_path: PathBufBase directory for storage.
encryptor: Option<Encryptor>Optional encryptor for encryption at rest.
Implementations§
Source§impl FilesystemBackend
impl FilesystemBackend
Sourcepub fn new(base_path: impl Into<PathBuf>) -> Self
pub fn new(base_path: impl Into<PathBuf>) -> Self
Creates a new filesystem backend.
If the encryption feature is enabled and SUBCOG_ENCRYPTION_KEY is set,
encryption at rest is automatically enabled.
§Errors
Returns an error if the directory cannot be created.
Sourcepub fn with_create(base_path: impl Into<PathBuf>) -> Result<Self>
pub fn with_create(base_path: impl Into<PathBuf>) -> Result<Self>
Creates a new filesystem backend with checked directory creation.
§Errors
Returns an error if the directory cannot be created.
Sourcefn try_create_encryptor() -> Option<Encryptor>
fn try_create_encryptor() -> Option<Encryptor>
Tries to create an encryptor from environment configuration.
Sourcefn decrypt_if_needed(&self, raw_data: Vec<u8>) -> Result<Vec<u8>>
fn decrypt_if_needed(&self, raw_data: Vec<u8>) -> Result<Vec<u8>>
Decrypts data if it’s encrypted, returns as-is otherwise.
This helper reduces nesting in the get method (clippy::excessive_nesting fix).
Sourcepub const fn encryption_enabled(&self) -> bool
pub const fn encryption_enabled(&self) -> bool
Returns whether encryption is enabled.
Sourcefn memory_path(&self, id: &MemoryId) -> Result<PathBuf>
fn memory_path(&self, id: &MemoryId) -> Result<PathBuf>
Returns the path for a memory file.
§Security
The memory ID is sanitized to prevent path traversal attacks. Only alphanumeric characters, dashes, and underscores are allowed.
Sourcefn is_safe_filename(name: &str) -> bool
fn is_safe_filename(name: &str) -> bool
Checks if a filename is safe (no path traversal).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FilesystemBackend
impl RefUnwindSafe for FilesystemBackend
impl Send for FilesystemBackend
impl Sync for FilesystemBackend
impl Unpin for FilesystemBackend
impl UnwindSafe for FilesystemBackend
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].