Struct juju::unitdata::Storage
[−]
[src]
pub struct Storage { /* fields omitted */ }
A connection to the unit's Key/Value data Simple key value database for local unit state within charms. Values are automatically json encoded/decoded.
Methods
impl Storage
[src]
fn new(path: Option<PathBuf>) -> Result<Self, JujuError>
Connect to the unit's database
fn get<T>(&self, key: &str) -> Result<Option<T>, JujuError> where T: Deserialize
fn getrange(&self,
key_prefix: &str,
strip: bool)
-> Result<HashMap<String, Value>, JujuError>
key_prefix: &str,
strip: bool)
-> Result<HashMap<String, Value>, JujuError>
Get a range of keys starting with a common prefix as a mapping of keys to values.
fn update<T>(&self,
mapping: HashMap<String, T>,
prefix: Option<String>)
-> Result<(), JujuError> where T: Serialize
mapping: HashMap<String, T>,
prefix: Option<String>)
-> Result<(), JujuError> where T: Serialize
Set the values of multiple keys at once. Accepts an optional prefix to apply to all keys before setting
fn unset(&self, key: &str) -> Result<(), JujuError>
Remove a key from the database entirely.
fn unsetrange(&self,
keys: Option<Vec<String>>,
prefix: Option<String>)
-> Result<u32, JujuError>
keys: Option<Vec<String>>,
prefix: Option<String>)
-> Result<u32, JujuError>
Remove a range of keys starting with a common prefix, from the database entirely. If keys is set to None it will delete all keys Returns number of rows deleted
fn set<T>(&self, key: &str, value: T) -> Result<(), JujuError> where T: Serialize
Set a value in the database.