Uci

Struct Uci 

Source
pub struct Uci(/* private fields */);
Expand description

Contains the native uci_context

Implementations§

Source§

impl Uci

Source

pub fn new() -> Result<Uci>

Creates a new UCI context. The C memory will be freed when the object is dropped.

Source

pub fn set_config_dir(&mut self, config_dir: &str) -> Result<()>

Sets the config directory of UCI, this is /etc/config by default.

Source

pub fn set_save_dir(&mut self, save_dir: &str) -> Result<()>

Sets the save directory of UCI, this is /tmp/.uci by default.

Source

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.

Source

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.

Source

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.

Source

pub fn commit(&mut self, package: &str) -> Result<()>

Commit all changes to the specified package writing the temporary delta to the config file

Source

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.

Trait Implementations§

Source§

impl Drop for Uci

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Uci

§

impl RefUnwindSafe for Uci

§

impl !Send for Uci

§

impl !Sync for Uci

§

impl Unpin for Uci

§

impl UnwindSafe for Uci

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.