pub struct JsonStorage { /* private fields */ }Expand description
JSON storage backend (default). JSON storage backend (default)
§Example
use rcman::{JsonStorage, StorageBackend};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
struct Config { name: String }
let storage = JsonStorage::new();
let data = Config { name: "test".into() };
let json = storage.serialize(&data).unwrap();
assert!(json.contains("test"));Implementations§
Trait Implementations§
Source§impl Clone for JsonStorage
impl Clone for JsonStorage
Source§fn clone(&self) -> JsonStorage
fn clone(&self) -> JsonStorage
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 Default for JsonStorage
impl Default for JsonStorage
Source§fn default() -> JsonStorage
fn default() -> JsonStorage
Returns the “default value” for a type. Read more
Source§impl StorageBackend for JsonStorage
impl StorageBackend for JsonStorage
Source§fn extension(&self) -> &'static str
fn extension(&self) -> &'static str
File extension for this storage format (e.g., “json”, “toml”) Read more
Source§fn serialize<T: Serialize>(&self, data: &T) -> Result<String>
fn serialize<T: Serialize>(&self, data: &T) -> Result<String>
Serialize data to string Read more
Source§fn deserialize<T: DeserializeOwned>(&self, content: &str) -> Result<T>
fn deserialize<T: DeserializeOwned>(&self, content: &str) -> Result<T>
Deserialize data from string Read more
Auto Trait Implementations§
impl Freeze for JsonStorage
impl RefUnwindSafe for JsonStorage
impl Send for JsonStorage
impl Sync for JsonStorage
impl Unpin for JsonStorage
impl UnsafeUnpin for JsonStorage
impl UnwindSafe for JsonStorage
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