pub struct Uci(/* private fields */);Expand description
Contains the native uci_context
Implementations§
Source§impl Uci
impl Uci
Sourcepub fn new() -> Result<Uci>
pub fn new() -> Result<Uci>
Creates a new UCI context. The C memory will be freed when the object is dropped.
Sourcepub fn set_config_dir(&mut self, config_dir: &str) -> Result<()>
pub fn set_config_dir(&mut self, config_dir: &str) -> Result<()>
Sets the config directory of UCI, this is /etc/config by default.
Sourcepub fn set_save_dir(&mut self, save_dir: &str) -> Result<()>
pub fn set_save_dir(&mut self, save_dir: &str) -> Result<()>
Sets the save directory of UCI, this is /tmp/.uci by default.
Sourcepub fn delete(&mut self, identifier: &str) -> Result<()>
pub fn delete(&mut self, identifier: &str) -> Result<()>
Delete an option or section in UCI.
UCI will keep the delta changes in a temporary location until commit() or revert() is called.
Allowed keys are like network.wan.proto, network.@interface[-1].iface, network.wan and network.@interface[-1]
if the deletion failed an Err is returned.
Sourcepub fn revert(&mut self, identifier: &str) -> Result<()>
pub fn revert(&mut self, identifier: &str) -> Result<()>
Revert changes to an option, section or package
Allowed keys are like network, network.wan.proto, network.@interface[-1].iface, network.wan and network.@interface[-1]
if the deletion failed an Err is returned.
Sourcepub fn set(&mut self, identifier: &str, val: &str) -> Result<()>
pub fn set(&mut self, identifier: &str, val: &str) -> Result<()>
Sets an option value or section type in UCI, creates the key if necessary.
UCI will keep the delta changes in a temporary location until commit() or revert() is called.
Allowed keys are like network.wan.proto, network.@interface[-1].iface, network.wan and network.@interface[-1]
if the assignment failed an Err is returned.
Sourcepub fn commit(&mut self, package: &str) -> Result<()>
pub fn commit(&mut self, package: &str) -> Result<()>
Commit all changes to the specified package writing the temporary delta to the config file
Sourcepub fn get(&mut self, key: &str) -> Result<String>
pub fn get(&mut self, key: &str) -> Result<String>
Queries an option value or section type from UCI. If a key has been changed in the delta, the updated value will be returned.
Allowed keys are like network.wan.proto, network.@interface[-1].iface, network.lan and network.@interface[-1]
if the entry does not exist an Err is returned.