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 OptionCodes to DhcpOptions 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§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<T> InstanceFromServiceTransport<T> for T
impl<T> InstanceFromServiceTransport<T> for T
§fn from_service_transport(handle: T) -> T
fn from_service_transport(handle: T) -> T
T to [Self]§impl<T> IntoAny for T
impl<T> IntoAny for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more