[−][src]Struct over::obj::Obj
Obj
struct.
Methods
impl Obj
[src]
pub fn from_map(obj_map: HashMap<String, Value>) -> OverResult<Obj>
[src]
Returns a new Obj
created from the given HashMap
.
Returns an error if the map contains an invalid field name. A valid field name must start with an alphabetic character or '' and subsequent characters must be alphabetic, numeric, or ''.
pub fn from_map_with_parent(
obj_map: HashMap<String, Value>,
parent: Obj
) -> OverResult<Obj>
[src]
obj_map: HashMap<String, Value>,
parent: Obj
) -> OverResult<Obj>
Returns a new Obj
created from the given HashMap
with given parent
.
Returns an error if the map contains an invalid field name.
See from_map
for more details.
pub fn from_map_unchecked(obj_map: HashMap<String, Value>) -> Obj
[src]
Returns a new Obj
created from the given HashMap
.
It is faster than the safe version, from_map
, if you know every field has a valid name.
You can check ahead of time whether a field is valid with is_valid_field
.
See from_map
for more details.
pub fn from_map_with_parent_unchecked(
obj_map: HashMap<String, Value>,
parent: Obj
) -> Obj
[src]
obj_map: HashMap<String, Value>,
parent: Obj
) -> Obj
Returns a new Obj
created from the given HashMap
with given parent
.
It is faster than the safe version, from_map_with_parent
, if you know every field has
a valid name. You can check ahead of time whether a field is valid with is_valid_field
.
See from_map
for more details.
pub fn id(&self) -> usize
[src]
Returns the ID of this Obj
.
Every Obj
is assigned its own globally unique ID. IDs are generated incrementally,
starting at 0 for the first Obj
created.
Notes
The ID is ignored when testing Obj
equality.
pub fn map_ref(&self) -> &HashMap<String, Value>
[src]
Returns a reference to the inner map of this Obj
.
pub fn from_file(path: &str) -> OverResult<Obj>
[src]
Returns a new Obj
loaded from a file.
pub fn write_to_file(&self, path: &str) -> OverResult<()>
[src]
Writes this Obj
to given file in .over
representation.
Notes
Note that the fields of the Obj
will be output in an unpredictable order.
Also note that shorthand in the original file, including variables and file includes,
is not preserved when parsing the file, and will not appear when writing to another file.
pub fn write_str(&self) -> String
[src]
pub fn with_each<F>(&self, f: F) where
F: FnMut(&String, &Value),
[src]
F: FnMut(&String, &Value),
Iterates over each (String, Value)
pair in self
, applying f
.
pub fn len(&self) -> usize
[src]
Returns the number of fields for this Obj
(parent fields not included).
pub fn is_empty(&self) -> bool
[src]
Returns whether this Obj
is empty.
pub fn ptr_eq(&self, other: &Self) -> bool
[src]
Returns whether self
and other
point to the same data.
pub fn contains(&self, field: &str) -> bool
[src]
Returns true if this Obj
contains field
.
pub fn get(&self, field: &str) -> Option<Value>
[src]
Gets the Value
associated with field
.
pub fn get_with_source(&self, field: &str) -> Option<(Value, Obj)>
[src]
Gets the Value
associated with field
and the Obj
where it was found (either self
or
one of its parents).
pub fn get_bool(&self, field: &str) -> OverResult<bool>
[src]
Returns the bool
found at field
. Returns an error if the field was not found or if the Value
at field
is not Bool
.
pub fn get_int(&self, field: &str) -> OverResult<BigInt>
[src]
Returns the BigInt
found at field
. Returns an error if the field was not found or if the Value
at field
is not Int
.
pub fn get_frac(&self, field: &str) -> OverResult<BigRational>
[src]
Returns the BigRational
found at field
. Returns an error if the field was not found or if the Value
at field
is not Frac
.
pub fn get_char(&self, field: &str) -> OverResult<char>
[src]
Returns the char
found at field
. Returns an error if the field was not found or if the Value
at field
is not Char
.
pub fn get_str(&self, field: &str) -> OverResult<String>
[src]
Returns the String
found at field
. Returns an error if the field was not found or if the Value
at field
is not Str
.
pub fn get_arr(&self, field: &str) -> OverResult<Arr>
[src]
Returns the Arr
found at field
. Returns an error if the field was not found or if the Value
at field
is not Arr
.
pub fn get_tup(&self, field: &str) -> OverResult<Tup>
[src]
Returns the Tup
found at field
. Returns an error if the field was not found or if the Value
at field
is not Tup
.
pub fn get_obj(&self, field: &str) -> OverResult<Obj>
[src]
Returns the Obj
found at field
. Returns an error if the field was not found or if the Value
at field
is not Obj
.
pub fn has_parent(&self) -> bool
[src]
Returns whether this Obj
has a parent.
pub fn get_parent(&self) -> Option<Obj>
[src]
Returns the parent for this Obj
.
pub fn is_valid_field(field: &str) -> bool
[src]
Returns true if field
is a valid field name for an Obj
.
The first character must be alphabetic or ''. Subsequent characters are allowed to be alphabetic, digits, or ''.
pub fn is_valid_field_char(ch: char, first: bool) -> bool
[src]
Returns true if the given char is valid for a field, depending on whether it is the first char or not.
See is_valid_field
for more details.
pub fn keys(&self) -> Keys<String, Value>
[src]
An iterator visiting all fields (keys) in arbitrary order.
pub fn values(&self) -> Values<String, Value>
[src]
An iterator visiting all values in arbitrary order.
pub fn iter(&self) -> Iter<String, Value>
[src]
An iterator visiting all field-value pairs in arbitrary order.
Trait Implementations
impl PartialEq<Obj> for Obj
[src]
For two Objs to be equal, the following two checks must pass:
- If either Obj has a parent, then both must have parents and the parents must be equal.
- The two Objs must have all the same fields pointing to the same values.
fn eq(&self, other: &Self) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialEq<Obj> for Value
[src]
fn eq(&self, other: &Obj) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialEq<Value> for Obj
[src]
fn eq(&self, other: &Value) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Default for Obj
[src]
impl From<Obj> for Value
[src]
impl Clone for Obj
[src]
fn clone(&self) -> Obj
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Display for Obj
[src]
impl Debug for Obj
[src]
impl FromStr for Obj
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From for T
[src]
impl<T, U> TryFrom 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> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,