pub struct FileStorageStrategy {
pub format: FormatStrategy,
pub atomic_write: AtomicWriteConfig,
pub load_behavior: LoadBehavior,
pub default_value: Option<Value>,
}Expand description
Strategy for file storage operations.
Fields§
§format: FormatStrategyFile format to use
atomic_write: AtomicWriteConfigAtomic write configuration
load_behavior: LoadBehaviorBehavior when file doesn’t exist
default_value: Option<Value>Default value to use when SaveIfMissing is set (as JSON Value)
Implementations§
Source§impl FileStorageStrategy
impl FileStorageStrategy
Sourcepub fn with_format(self, format: FormatStrategy) -> Self
pub fn with_format(self, format: FormatStrategy) -> Self
Set the file format.
Sourcepub fn with_retry_count(self, count: usize) -> Self
pub fn with_retry_count(self, count: usize) -> Self
Set the retry count for atomic writes.
Sourcepub fn with_cleanup(self, cleanup: bool) -> Self
pub fn with_cleanup(self, cleanup: bool) -> Self
Set whether to cleanup temporary files.
Sourcepub fn with_load_behavior(self, behavior: LoadBehavior) -> Self
pub fn with_load_behavior(self, behavior: LoadBehavior) -> Self
Set the load behavior.
Sourcepub fn with_default_value(self, value: JsonValue) -> Self
pub fn with_default_value(self, value: JsonValue) -> Self
Set the default value to use when SaveIfMissing is set.
This value will be used as the initial content when a file doesn’t exist
and LoadBehavior::SaveIfMissing is configured.
§Example
ⓘ
use serde_json::json;
let strategy = FileStorageStrategy::new()
.with_load_behavior(LoadBehavior::SaveIfMissing)
.with_default_value(json!({
"test": [{"name": "default", "count": 0}]
}));Trait Implementations§
Source§impl Clone for FileStorageStrategy
impl Clone for FileStorageStrategy
Source§fn clone(&self) -> FileStorageStrategy
fn clone(&self) -> FileStorageStrategy
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FileStorageStrategy
impl Debug for FileStorageStrategy
Auto Trait Implementations§
impl Freeze for FileStorageStrategy
impl RefUnwindSafe for FileStorageStrategy
impl Send for FileStorageStrategy
impl Sync for FileStorageStrategy
impl Unpin for FileStorageStrategy
impl UnwindSafe for FileStorageStrategy
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