pub trait Miniconf {
// Required methods
fn set_path<'a, P: Peekable<Item = &'a str>>(
&mut self,
path_parts: &'a mut P,
value: &[u8]
) -> Result<usize, Error>;
fn get_path<'a, P: Peekable<Item = &'a str>>(
&self,
path_parts: &'a mut P,
value: &mut [u8]
) -> Result<usize, Error>;
fn next_path<const TS: usize>(
state: &mut [usize],
path: &mut String<TS>
) -> Result<bool, IterError>;
fn metadata() -> Metadata;
// Provided methods
fn set(&mut self, path: &str, data: &[u8]) -> Result<usize, Error> { ... }
fn get(&self, path: &str, data: &mut [u8]) -> Result<usize, Error> { ... }
fn iter_paths<const L: usize, const TS: usize>(
) -> Result<MiniconfIter<Self, L, TS>, IterError> { ... }
fn unchecked_iter_paths<const L: usize, const TS: usize>(
count: Option<usize>
) -> MiniconfIter<Self, L, TS> ⓘ { ... }
}Expand description
Trait exposing serialization/deserialization of elements by path.
Required Methods§
sourcefn set_path<'a, P: Peekable<Item = &'a str>>(
&mut self,
path_parts: &'a mut P,
value: &[u8]
) -> Result<usize, Error>
fn set_path<'a, P: Peekable<Item = &'a str>>( &mut self, path_parts: &'a mut P, value: &[u8] ) -> Result<usize, Error>
sourcefn get_path<'a, P: Peekable<Item = &'a str>>(
&self,
path_parts: &'a mut P,
value: &mut [u8]
) -> Result<usize, Error>
fn get_path<'a, P: Peekable<Item = &'a str>>( &self, path_parts: &'a mut P, value: &mut [u8] ) -> Result<usize, Error>
sourcefn next_path<const TS: usize>(
state: &mut [usize],
path: &mut String<TS>
) -> Result<bool, IterError>
fn next_path<const TS: usize>( state: &mut [usize], path: &mut String<TS> ) -> Result<bool, IterError>
Get the next path in the namespace.
This is usually not called directly but through a MiniconfIter returned by Miniconf::iter_paths.
Args
state: A state array indicating the path to be retrieved. A zeroed vector indicates the first path. The vector is advanced such that the next element will be retrieved when called again. The array needs to be at least as long as the maximum path depth.path: A string to write the path into.
Returns
A bool indicating a valid path was written to path from the given state.
If false, path is invalid and there are no more paths within self at and
beyond state.
May return IterError indicating insufficient state or path size.
Provided Methods§
sourcefn iter_paths<const L: usize, const TS: usize>(
) -> Result<MiniconfIter<Self, L, TS>, IterError>
fn iter_paths<const L: usize, const TS: usize>( ) -> Result<MiniconfIter<Self, L, TS>, IterError>
Create an iterator of all possible paths.
This is a depth-first walk. The iterator will walk all paths, even those that may be absent at run-time (see Option). The iterator has an exact and trusted Iterator::size_hint.
Template Arguments
L- The maximum depth of the path, i.e. number of separators plus 1.TS- The maximum length of the path in bytes.
Returns
A MiniconfIter of paths or an IterError if L or TS are insufficient.
sourcefn unchecked_iter_paths<const L: usize, const TS: usize>(
count: Option<usize>
) -> MiniconfIter<Self, L, TS> ⓘ
fn unchecked_iter_paths<const L: usize, const TS: usize>( count: Option<usize> ) -> MiniconfIter<Self, L, TS> ⓘ
Create an iterator of all possible paths.
This is a depth-first walk. It will return all paths, even those that may be absent at run-time.
Note
This does not check that the path size or state vector are large enough. If they are not, panics may be generated internally by the library.
Args
count: Optional iterator length if known.
Template Arguments
L- The maximum depth of the path, i.e. number of separators plus 1.TS- The maximum length of the path in bytes.