pub struct Stash { /* private fields */ }
Expand description
A wrapper around a fuchsia.stash.StoreAccessor
proxy.
Stash provides a simple API by which the DHCP Server
can store and load client configuration
data to persistent storage.
This wrapper stores client configuration as serialized JSON strings. The decision to use JSON derives from its use in other Stash clients, cf. commit e9c57a0, and the relative immaturity of more compact serde serialization formats, e.g. https://github.com/pyfisch/cbor/issues.
Implementations§
source§impl Stash
impl Stash
sourcepub fn new(id: &str) -> Result<Self, StashError>
pub fn new(id: &str) -> Result<Self, StashError>
Instantiates a new Stash
value.
The newly instantiated value will use id
to identify itself with the fuchsia.stash
service.
sourcepub async fn load_client_records(&self) -> Result<ClientRecords, StashError>
pub async fn load_client_records(&self) -> Result<ClientRecords, StashError>
Loads a ClientRecords
map from data stored in fuchsia.stash
.
This function will retrieve all client configuration data from fuchsia.stash
, deserialize
the JSON string values, and load the resulting structured data into a ClientRecords
hashmap. Any key-value pair which could not be parsed or deserialized will be removed and
skipped.
sourcepub async fn load_options(
&self
) -> Result<HashMap<OptionCode, DhcpOption>, StashError>
pub async fn load_options( &self ) -> Result<HashMap<OptionCode, DhcpOption>, StashError>
Loads a map of OptionCode
s to DhcpOption
s from data stored in fuchsia.stash
.
sourcepub async fn load_parameters(&self) -> Result<ServerParameters, StashError>
pub async fn load_parameters(&self) -> Result<ServerParameters, StashError>
Loads a new instance of ServerParameters
from data stored in fuchsia.stash
.
sourcepub fn clear(&self) -> Result<(), StashError>
pub fn clear(&self) -> Result<(), StashError>
Clears all configuration data from fuchsia.stash
.
This function will delete all key-value pairs associated with the Stash
value.