Struct Table

Source
pub struct Table { /* private fields */ }
Expand description

Contains Values indexed by a string name.

§Examples

TODO

Implementations§

Source§

impl Table

Source

pub fn new() -> Table

Constructs a new, empty table.

Source

pub fn with_map(map: HashMap<String, Value>) -> Table

Constructs a new table from the given initial map.

Source

pub fn exists(&self, name: &str) -> bool

Checks if the given key exists in the map.

Source

pub fn get<'a, T>(&'a self, name: &str) -> Option<T>
where T: FromValue<'a>,

Gets and parses the value with the given name and returns it, or returns None if the value doesn’t exist or can’t be parsed as this type.

Source

pub fn get_mut<'a, T>(&'a mut self, name: &str) -> Option<T>
where T: FromValueMut<'a>,

Gets and parses the value with the given name and returns it, or returns None if the value doesn’t exist or can’t be parsed as this type.

Source

pub fn set<T>(&mut self, name: &str, value: T) -> Option<Value>
where Value: From<T>,

Updates the value assigned to this name, returning the previous one if it existed.

Source

pub fn remove(&mut self, name: &str) -> Option<Value>

Removes any assignment of a value to this name, returning it if it existed.

Source

pub fn clear(&mut self)

Removes all value assignments, resetting this table to a new state.

Source

pub fn iter<'a>(&'a self) -> Iter<'a, String, Value>

Produces an iterator over the keys and values in this table.

Currently, this method only delegates to the inner HashMap::iter().

Source

pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, String, Value>

Produces a mutable iterator over the keys and values in this table.

Currently, this method only delegates to HashMap::iter_mut().

Trait Implementations§

Source§

impl Clone for Table

Source§

fn clone(&self) -> Table

Returns a duplicate 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 Table

Source§

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

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

impl Default for Table

Source§

fn default() -> Table

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Table

Source§

fn deserialize<D>(deserializer: D) -> Result<Table, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<HashMap<String, Value>> for Table

Source§

fn from(map: HashMap<String, Value>) -> Table

Converts to this type from the input type.
Source§

impl From<Table> for Value

Source§

fn from(x: Table) -> Value

Converts to this type from the input type.
Source§

impl<'a> FromValue<'a> for &'a Table

Source§

fn from_value(value: &'a Value) -> Option<&'a Table>

Attempts to perform the conversion, returning None if the given value can not be used to produce Self.
Source§

impl<'a> FromValueMut<'a> for &'a mut Table

Source§

fn from_value_mut(value: &'a mut Value) -> Option<&'a mut Table>

Attempts to perform the conversion, returning None if the given value can not be used to produce Self.
Source§

impl<'a> IntoIterator for &'a Table

Source§

type Item = (&'a String, &'a Value)

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, String, Value>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a> IntoIterator for &'a mut Table

Source§

type Item = (&'a String, &'a mut Value)

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, String, Value>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for Table

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Table

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Table

Auto Trait Implementations§

§

impl Freeze for Table

§

impl RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl UnwindSafe for Table

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,