[][src]Struct libucl::object::Object

pub struct Object { /* fields omitted */ }

File element object.

This structure is immutable typed reference to object inside parsed tree. It can be one of Type elements and can be cast only to given type.

Methods

impl Object[src]

pub fn dump_into(&self, emmiter: Emitter) -> String[src]

pub fn dump(&self) -> String[src]

pub fn size(&self) -> usize[src]

pub fn at(&self, i: usize) -> Option<Object>[src]

pub fn iter_reset(&mut self)[src]

pub fn key(&self) -> Option<String>[src]

Return key assigned to object.

pub fn get_type(&self) -> Type[src]

Return type of object.

pub fn as_int(&self) -> Option<i64>[src]

Return i64 value

Examples

let obj = libucl::object::Builder::from(10).build();
assert_eq!(obj.as_int(), Some(10));

let obj = libucl::object::Builder::from("test_string").build();
assert_eq!(obj.as_int(), None);

pub fn as_float(&self) -> Option<f64>[src]

Return f64 value

Examples

let obj = libucl::object::Builder::from(10f64).build();
assert_eq!(obj.as_float(), Some(10.0));

let obj = libucl::object::Builder::from("test_string").build();
assert_eq!(obj.as_float(), None);

pub fn as_bool(&self) -> Option<bool>[src]

Return boolean value

Examples

let obj = libucl::object::Builder::from(true).build();
assert_eq!(obj.as_bool(), Some(true));

let obj = libucl::object::Builder::from(10).build();
assert_eq!(obj.as_bool(), None);

pub fn as_string(&self) -> Option<String>[src]

Return string value

Examples

let obj = libucl::object::Builder::from("test_string").build();
assert_eq!(obj.as_string(), Some("test_string".to_string()));

let obj = libucl::object::Builder::from(10).build();
assert_eq!(obj.as_string(), None);

pub fn fetch<T: AsRef<str>>(&self, key: T) -> Option<Object>[src]

Fetch object under key

Examples

let obj = libucl::Parser::new().parse("a = b;").unwrap();
assert_eq!(obj.fetch("a").unwrap().as_string(), Some("b".to_string()));

pub fn fetch_path<T: AsRef<str>>(&self, path: T) -> Option<Object>[src]

Fetch object at the end of path delimeted by . (dot)

Examples

let obj = libucl::Parser::new().parse("a = { b = c; }").unwrap();
assert_eq!(obj.fetch_path("a.b").unwrap().as_string(), Some("c".to_string()));

pub fn validate_with_schema(
    &self,
    schema: &Object
) -> Result<(), UclSchemaError>
[src]

Trait Implementations

impl AsRef<Object> for Object[src]

impl Debug for Object[src]

impl Drop for Object[src]

impl Into<Object> for Builder[src]

impl Iterator for Object[src]

type Item = Object

The type of the elements being iterated over.

Auto Trait Implementations

impl RefUnwindSafe for Object

impl !Send for Object

impl !Sync for Object

impl Unpin for Object

impl UnwindSafe for Object

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<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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.