[][src]Enum mininip::datas::Value

pub enum Value {
    Raw(String),
    Str(String),
    Int(i64),
    Float(f64),
    Bool(bool),
}

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 integer
  • Float: a 64 bytes-sized floating-point number
  • Bool: a boolean (currently either on or off)

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 escaped
  • Str is backed up with two quotes ' or " around its value once escaped
  • Int is backed up as is
  • Float is backed up as is
  • Bool is backed up as two different values: true and false

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.