[−][src]Struct scfg::Scfg
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
impl Scfg
[src]
pub fn new() -> Self
[src]
Creates a new empty document
pub fn get<Q: ?Sized>(&self, name: &Q) -> Option<&Directive> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
String: Borrow<Q>,
Q: Ord + Eq + Hash,
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.
pub fn get_all<Q: ?Sized>(&self, name: &Q) -> Option<&[Directive]> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
String: Borrow<Q>,
Q: Ord + Eq + Hash,
Retrieves the all directives with a particular name.
pub fn get_all_mut<Q: ?Sized>(
&mut self,
name: &Q
) -> Option<&mut Vec<Directive>> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
&mut self,
name: &Q
) -> Option<&mut Vec<Directive>> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
Retrieves a mutable reference to all directives with a particular name.
pub fn contains<Q: ?Sized>(&self, name: &Q) -> bool where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
String: Borrow<Q>,
Q: Ord + Eq + Hash,
Does the document contain a directive with name
.
let mut scfg = Scfg::new(); scfg.add("foo"); assert!(scfg.contains("foo")); assert!(!scfg.contains("bar"));
pub fn add(&mut self, name: impl Into<String>) -> &mut Directive
[src]
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.
pub fn remove<Q: ?Sized>(&mut self, name: &Q) -> Option<Vec<Directive>> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
String: Borrow<Q>,
Q: Ord + Eq + Hash,
Removes all directives with the supplied name, returning them.
pub fn remove_entry<Q: ?Sized>(
&mut self,
name: &Q
) -> Option<(String, Vec<Directive>)> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
&mut self,
name: &Q
) -> Option<(String, Vec<Directive>)> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
Removes all directives with the supplied name, returning them, and their key.
pub fn write<W>(&self, writer: &mut W) -> Result<()> where
W: Write,
[src]
W: Write,
Writes the document to the specified writer. If efficiency is a concern,
it may be best to wrap the writer in a [BufWriter
] first. This will
not write any comments that the document had if it was parsed first.
Trait Implementations
impl Clone for Scfg
[src]
impl Debug for Scfg
[src]
impl Default for Scfg
[src]
impl Eq for Scfg
[src]
impl<K: Into<String>> FromIterator<(K, Directive)> for Scfg
[src]
impl FromStr for Scfg
[src]
type Err = ParseError
The associated error which can be returned from parsing.
fn from_str(src: &str) -> Result<Self, Self::Err>
[src]
impl PartialEq<Scfg> for Scfg
[src]
impl StructuralEq for Scfg
[src]
impl StructuralPartialEq for Scfg
[src]
Auto Trait Implementations
impl RefUnwindSafe for Scfg
impl Send for Scfg
impl Sync for Scfg
impl Unpin for Scfg
impl UnwindSafe for Scfg
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,