pub struct Parser { /* private fields */ }Expand description
A configurable KeyValues parser allowing for adjusting settings before parsing
Implementations§
Source§impl Parser
impl Parser
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Constructs a default parser
Currently this consists of:
| Toggle | Description |
|---|---|
Parser::literal_special_chars() | Whether to interpret \ in strings as the start of an escaped special character, or a literal \ |
Sourcepub const fn literal_special_chars(self, yes: bool) -> Self
pub const fn literal_special_chars(self, yes: bool) -> Self
Toggle how to interpret \ in strings
By default (false) the parser will interpret backslashes (\) in strings as the start of
an escaped special character (e.g. \\ -> \, \" -> "). When true the parser will
instead interpret backslashes (\) as a literal backslash. Commonly seen with
windows-paths, for instance
Sourcepub fn parse<'text>(&self, vdf: &'text str) -> Result<PartialVdf<'text>>
pub fn parse<'text>(&self, vdf: &'text str) -> Result<PartialVdf<'text>>
Parse a KeyValues document to a loosely typed representation
§Example
use keyvalues_parser::Parser;
let vdf = Parser::new()
.literal_special_chars(true)
.parse(r"InstallDir C:\You\Later")
.unwrap();
assert_eq!(vdf.value.unwrap_str(), r"C:\You\Later");Trait Implementations§
Auto Trait Implementations§
impl Freeze for Parser
impl RefUnwindSafe for Parser
impl Send for Parser
impl Sync for Parser
impl Unpin for Parser
impl UnwindSafe for Parser
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