Trait miniconf::JsonCoreSlash
source · pub trait JsonCoreSlash<'de, const Y: usize = 1>: TreeSerialize<Y> + TreeDeserialize<'de, Y> {
// Required methods
fn set_json(
&mut self,
path: &str,
data: &'de [u8]
) -> Result<usize, Error<Error>>;
fn get_json(
&self,
path: &str,
data: &mut [u8]
) -> Result<usize, Error<Error>>;
fn set_json_by_key<K: IntoKeys>(
&mut self,
keys: K,
data: &'de [u8]
) -> Result<usize, Error<Error>>;
fn get_json_by_key<K: IntoKeys>(
&self,
keys: K,
data: &mut [u8]
) -> Result<usize, Error<Error>>;
}Expand description
TreeSerialize/TreeDeserialize with “JSON and /”.
Access items with '/' as path separator and JSON (from serde-json-core)
as serialization/deserialization payload format.
Paths used here are reciprocal to TreeKey::path(..., "/")/TreeKey::iter_paths("/").
use miniconf::{JsonCoreSlash, Tree};
#[derive(Tree, Default)]
struct S {
foo: u32,
#[tree(depth=1)]
bar: [u16; 2],
};
let mut s = S::default();
s.set_json("/bar/1", b"9").unwrap();
assert_eq!(s.bar[1], 9);
let mut buf = [0u8; 10];
let len = s.get_json("/bar/1", &mut buf[..]).unwrap();
assert_eq!(&buf[..len], b"9");Required Methods§
Object Safety§
This trait is not object safe.