Enum acon::Acon

source ·
pub enum Acon {
    Array(Array),
    String(String),
    Table(Table),
}
Expand description

Enumeration over all variable types in ACON

Variants§

§

Array(Array)

Array type contains a Vec of Acon

§

String(String)

String type contains a simple std::string::String

§

Table(Table)

Table consists of a BTreeMap<String, Acon>

Implementations§

source§

impl Acon

source

pub fn array(&self) -> &Array

Assert that this value is an array, else panic

source

pub fn string(&self) -> &String

Assert that this value is a string, else panic

source

pub fn table(&self) -> &Table

Assert that this value is a table, else panic

source

pub fn path(&self, path: &str) -> Option<&Acon>

Retrieve a reference to an entry via its path Paths are dot-separated.

use acon::Acon;
let input = r#"
{ table
  [ array
    value
$
"#;
let result = input.parse::<Acon>().unwrap();
assert_eq!(result.path("table.array.0").unwrap().string(), "value");
source

pub fn path_mut(&mut self, path: &str) -> Option<&mut Acon>

Retrieve a mutable reference to an entry via its path. Paths are dot-separated.

source

pub fn get(&self, path: &str) -> Option<&Acon>

Retrieve a reference to an entry

source

pub fn get_mut(&mut self, path: &str) -> Option<&mut Acon>

Retrieve a mutable reference to an entry

Trait Implementations§

source§

impl Clone for Acon

source§

fn clone(&self) -> Acon

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Acon

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Acon

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl FromStr for Acon

source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parse a string into an Acon value

use acon::Acon;
let input = r#"
  key value
  { table-name
    key value
    key2 value2
  }
"#;
let result = input.parse::<Acon>().unwrap();
match result {
  Acon::Table(_) => assert!(true),
  _ => assert!(false),
}
§

type Err = AconError

The associated error which can be returned from parsing.
source§

impl PartialEq<Acon> for Acon

source§

fn eq(&self, other: &Acon) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Acon

Auto Trait Implementations§

§

impl RefUnwindSafe for Acon

§

impl Send for Acon

§

impl Sync for Acon

§

impl Unpin for Acon

§

impl UnwindSafe for Acon

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.