pub struct OptionsCollection {
pub options: Vec<OptionInfo>,
}Expand description
An owned snapshot of every option in a cpdb_options_t.
Built from D-Bus GetAllOptions responses (zbus backend) or from
C cpdb_options_t pointers (FFI backend). After construction, no raw
pointers are held - the collection is freely movable and cloneable.
§Example
use cpdb_rs::options::{OptionsCollection, OptionInfo};
let col = OptionsCollection {
options: vec![OptionInfo {
name: "copies".to_string(),
default_value: "1".to_string(),
group: "General".to_string(),
supported_values: vec!["1".to_string(), "2".to_string()],
}],
};
assert_eq!(col.get("copies").unwrap().default_value, "1");Fields§
§options: Vec<OptionInfo>Every option discovered, in iteration order of the underlying hash table (which itself is implementation-defined).
Implementations§
Source§impl OptionsCollection
impl OptionsCollection
Sourcepub fn from_dbus(raw: Vec<RawOption>) -> Self
Available on crate feature zbus-backend only.
pub fn from_dbus(raw: Vec<RawOption>) -> Self
zbus-backend only.Builds an OptionsCollection from the D-Bus response tuples returned
by crate::proxy::PrintBackendProxy::get_all_options().
Sourcepub fn get(&self, name: &str) -> Option<&OptionInfo>
pub fn get(&self, name: &str) -> Option<&OptionInfo>
Finds an option by name (linear search).
Sourcepub fn iter(&self) -> impl Iterator<Item = &OptionInfo>
pub fn iter(&self) -> impl Iterator<Item = &OptionInfo>
Returns an iterator over all options.
Trait Implementations§
Source§impl Clone for OptionsCollection
impl Clone for OptionsCollection
Source§fn clone(&self) -> OptionsCollection
fn clone(&self) -> OptionsCollection
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OptionsCollection
impl Debug for OptionsCollection
Source§impl Default for OptionsCollection
impl Default for OptionsCollection
Source§fn default() -> OptionsCollection
fn default() -> OptionsCollection
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for OptionsCollection
impl RefUnwindSafe for OptionsCollection
impl Send for OptionsCollection
impl Sync for OptionsCollection
impl Unpin for OptionsCollection
impl UnsafeUnpin for OptionsCollection
impl UnwindSafe for OptionsCollection
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