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.
Trait Implementations§
Source§impl DataStore for Stash
impl DataStore for Stash
type Error = StashError
Source§fn insert(
&mut self,
client_id: &ClientIdentifier,
client_record: &LeaseRecord,
) -> Result<(), Self::Error>
fn insert( &mut self, client_id: &ClientIdentifier, client_record: &LeaseRecord, ) -> Result<(), Self::Error>
Source§fn store_options(&mut self, opts: &[DhcpOption]) -> Result<(), Self::Error>
fn store_options(&mut self, opts: &[DhcpOption]) -> Result<(), Self::Error>
Source§fn store_parameters(
&mut self,
params: &ServerParameters,
) -> Result<(), Self::Error>
fn store_parameters( &mut self, params: &ServerParameters, ) -> Result<(), Self::Error>
Auto Trait Implementations§
impl Freeze for Stash
impl !RefUnwindSafe for Stash
impl Send for Stash
impl Sync for Stash
impl Unpin for Stash
impl !UnwindSafe for Stash
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)