pub struct Config {}
Expand description
Struct for Apt Configuration
All apt configuration methods do not require this struct. You can call the bindings directly from raw::apt if you would like.
Implementations
sourceimpl Config
impl Config
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new config object and safely init the config system.
If you initialize the struct without new()
or default()
You will need to manually initialize the config system.
sourcepub fn new_clear() -> Self
pub fn new_clear() -> Self
Clears all configuratations, re-initialize, and returns the config object.
sourcepub fn reset(&self)
pub fn reset(&self)
Resets the configurations.
If you’d like to clear everything and NOT reinit
you can call self.clear_all
or apt::config_clear_all
directly
sourcepub fn clear(&self, key: &str)
pub fn clear(&self, key: &str)
Clears all values from a key.
If the value is a list, the entire list is cleared.
If you need to clear 1 value from a list see self.clear_value
sourcepub fn clear_value(&self, key: &str, value: &str)
pub fn clear_value(&self, key: &str, value: &str)
Clear a single value from a list. Used for removing one item in an apt configuruation list
sourcepub fn clear_all(&self)
pub fn clear_all(&self)
Clears all configuratations.
This will leave you with an empty configuration object and most things probably won’t work right.
sourcepub fn find(&self, key: &str, default: &str) -> String
pub fn find(&self, key: &str, default: &str) -> String
Find a key and return it’s value as a string.
default is what will be returned if nothing is found.
sourcepub fn get(&self, key: &str) -> Option<String>
pub fn get(&self, key: &str) -> Option<String>
Exactly like find but takes no default and returns an option instead.
sourcepub fn file(&self, key: &str, default: &str) -> String
pub fn file(&self, key: &str, default: &str) -> String
Find a file and return it’s value as a string.
default is what will be returned if nothing is found.
key = "Dir::Cache::pkgcache"
should return
/var/cache/apt/pkgcache.bin
There is not much difference in self.dir
and self.file
dir
will return with a trailing /
where file
will not.
sourcepub fn dir(&self, key: &str, default: &str) -> String
pub fn dir(&self, key: &str, default: &str) -> String
Find a directory and return it’s value as a string.
default is what will be returned if nothing is found.
key = "Dir::Etc::sourceparts"
should return /etc/apt/sources.list.d/
There is not much difference in self.dir
and self.file
dir
will return with a trailing /
where file
will not.
sourcepub fn find_vector(&self, key: &str) -> Vec<String>
pub fn find_vector(&self, key: &str) -> Vec<String>
Return a vector for an Apt configuration list.
An example of a common key that contains a list APT::NeverAutoRemove
.
sourcepub fn set_vector(&self, key: &str, values: &Vec<&str>)
pub fn set_vector(&self, key: &str, values: &Vec<&str>)
Add strings from a vector into an apt configuration list.
If the configuration key is not a list, you will receive a vector with one item.
Example:
use rust_apt::config::Config;
let config = Config::new();
let apt_list = vec!["This", "is", "my", "apt", "list"];
// Using "AptList" here will not work and will panic.
config.set_vector("AptList", &apt_list);
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more