pub struct Section<T: ?Sized + Borrow<JObject>>(/* private fields */);Expand description
Part of a Config object, may contain sub-sections
Implementations§
Source§impl<T: ?Sized + Borrow<JObject>> Section<T>
impl<T: ?Sized + Borrow<JObject>> Section<T>
Sourcepub fn read_value<K, V>(&self, key: &K) -> Result<V, Error>
pub fn read_value<K, V>(&self, key: &K) -> Result<V, Error>
Reads a value from the given key, if the key does not exist returns Err
Sourcepub fn get_section<K>(&self, key: &K) -> Result<Section<&JObject>, Error>
pub fn get_section<K>(&self, key: &K) -> Result<Section<&JObject>, Error>
Gets an immutable reference to Section at the given key
Sourcepub fn clone_data(&self) -> JObject
pub fn clone_data(&self) -> JObject
Clones the Section data, the result does not have any reference to the original Config nor Section
Source§impl<T: ?Sized + BorrowMut<JObject>> Section<T>
impl<T: ?Sized + BorrowMut<JObject>> Section<T>
Sourcepub fn write_value<K: Into<String>, V: Serialize>(
&mut self,
key: K,
value: V,
) -> Result<(), Error>
pub fn write_value<K: Into<String>, V: Serialize>( &mut self, key: K, value: V, ) -> Result<(), Error>
Writes a valute to the given key, if it doesn’t exist, inserts the key value pair
Sourcepub fn read_or_insert<K: Into<String>, V: DeserializeOwned + Serialize + Clone>(
&mut self,
key: K,
value: V,
) -> Result<V, Error>
pub fn read_or_insert<K: Into<String>, V: DeserializeOwned + Serialize + Clone>( &mut self, key: K, value: V, ) -> Result<V, Error>
Reads a value from the given key, if the key does not exists, inserts it with the given value
Sourcepub fn update_value<K, V, Out, F>(
&mut self,
key: &K,
f_upd: F,
) -> Result<Out, Error>
pub fn update_value<K, V, Out, F>( &mut self, key: &K, f_upd: F, ) -> Result<Out, Error>
Updates a value with the given key using the provided function, returns the final value of the key, if the key does not exist returns Err
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Section<T>
impl<T> RefUnwindSafe for Section<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for Section<T>
impl<T> Sync for Section<T>
impl<T> Unpin for Section<T>
impl<T> UnwindSafe for Section<T>where
T: UnwindSafe + ?Sized,
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
Mutably borrows from an owned value. Read more