[−][src]Enum mininip::datas::Value
The value of a INI variable
The following types are available
Raw
: the raw content of the file, not formatted. The only computation is that the escaped characters are unescaped (see parse_str to learn more about escaped characters)Str
: a quoted string written inside non-escaped quotes like that"Hello world!"
or that'Hello world!'
Int
: a 64 bytes-sized integerFloat
: a 64 bytes-sized floating-point numberBool
: a boolean (currently eitheron
oroff
)
Each type is represented as an enum variant
Variants
Raw(String)
Str(String)
Int(i64)
Float(f64)
Bool(bool)
Methods
impl Value
[src]
pub fn parse(content: &str) -> Result<Value, Error>
[src]
Builds a new Value
from content
, an INI-formatted string
Return value
Ok(value)
with value
as the new object
Err(error)
when an error occurs while parsing content
with error
as the error code
pub fn dump(&self) -> String
[src]
Formats self
to be dumped in an INI file
It means that format!("{}={}", ident, value.dump())
with ident
as a valid key and value
a Value
can be properly registered and then, parsed as INI
Return value
A String
containing the value of self
once formatted
See
See dump_str
for more informations about this format
Note
self
is backed up in a way preserving its type
Raw
is backed up as is, once escapedStr
is backed up with two quotes'
or"
around its value once escapedInt
is backed up as isFloat
is backed up as isBool
is backed up as two different values:true
andfalse
Examples
use mininip::datas::Value; let val = Value::Str(String::from("très_content=☺ ; the symbol of hapiness")); let dumped = val.dump(); assert_eq!(dumped, "'tr\\x0000e8s_content\\=\\x00263a \\; the symbol of hapiness'"); // Notice the quotes here
Trait Implementations
impl Clone for Value
[src]
impl Debug for Value
[src]
impl Default for Value
[src]
impl Display for Value
[src]
impl PartialEq<Value> for Value
[src]
impl StructuralPartialEq for Value
[src]
Auto Trait Implementations
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
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,
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.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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.
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>,