pub struct Scfg { /* private fields */ }
Expand description
An scfg document. Implemented as a multimap.
If the preserve_order
feature is enabled, the directive names will be kept
in the order of their first appearance. Otherwise, they will be sorted by name.
Implementations§
source§impl Scfg
impl Scfg
sourcepub fn get<Q>(&self, name: &Q) -> Option<&Directive>
pub fn get<Q>(&self, name: &Q) -> Option<&Directive>
Retrieves the first directive with a particular name.
This will return None
if either, the name is not found, or if the name
somehow has no directives.
sourcepub fn get_all<Q>(&self, name: &Q) -> Option<&[Directive]>
pub fn get_all<Q>(&self, name: &Q) -> Option<&[Directive]>
Retrieves the all directives with a particular name.
sourcepub fn get_all_mut<Q>(&mut self, name: &Q) -> Option<&mut Vec<Directive>>
pub fn get_all_mut<Q>(&mut self, name: &Q) -> Option<&mut Vec<Directive>>
Retrieves a mutable reference to all directives with a particular name.
sourcepub fn contains<Q>(&self, name: &Q) -> bool
pub fn contains<Q>(&self, name: &Q) -> bool
Does the document contain a directive with name
.
let mut scfg = Scfg::new();
scfg.add("foo");
assert!(scfg.contains("foo"));
assert!(!scfg.contains("bar"));
sourcepub fn add(&mut self, name: impl Into<String>) -> &mut Directive
pub fn add(&mut self, name: impl Into<String>) -> &mut Directive
Adds a new name returning the new (empty) directive.
let mut scfg = Scfg::new();
let dir = scfg.add("dir1");
assert_eq!(*dir, Directive::default());
§Note
This does not validate that name
is a legal scfg word. It is possible to create
unparsable documents should name
contain control characters or newlines.
sourcepub fn remove<Q>(&mut self, name: &Q) -> Option<Vec<Directive>>
pub fn remove<Q>(&mut self, name: &Q) -> Option<Vec<Directive>>
Removes all directives with the supplied name, returning them.
Trait Implementations§
impl Eq for Scfg
impl StructuralPartialEq for Scfg
Auto Trait Implementations§
impl Freeze for Scfg
impl RefUnwindSafe for Scfg
impl Send for Scfg
impl Sync for Scfg
impl Unpin for Scfg
impl UnwindSafe for Scfg
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)