Skip to main content

ConfigView

Struct ConfigView 

Source
pub struct ConfigView<'a> { /* private fields */ }
Expand description

Borrowed typed accessors over one config table.

Implementations§

Source§

impl<'a> ConfigView<'a>

Source

pub fn new(table: &'a ConfigTable) -> Self

Creates a view over table.

Source

pub fn from_entries(entries: &'a [(Expr, Expr)]) -> Self

Creates a view over already-borrowed table entries.

Source

pub fn get(&self, key: &str) -> Option<&'a Expr>

Returns the raw expression for key.

Source

pub fn string(&self, key: &str) -> Option<&'a str>

Reads an optional string field.

Source

pub fn required_string(&self, key: &str) -> ConfigResult<&'a str>

Reads a required string field.

Source

pub fn bool(&self, key: &str) -> Option<bool>

Reads an optional boolean field.

Source

pub fn required_bool(&self, key: &str) -> ConfigResult<bool>

Reads a required boolean field.

Source

pub fn i64(&self, key: &str) -> Option<i64>

Reads an optional integer field.

Source

pub fn required_i64(&self, key: &str) -> ConfigResult<i64>

Reads a required integer field.

Source

pub fn list(&self, key: &str) -> Option<&'a [Expr]>

Borrows a list field.

Source

pub fn table(&self, key: &str) -> Option<&'a [(Expr, Expr)]>

Borrows a nested table field.

Source

pub fn string_array(&self, key: &str) -> ConfigResult<Vec<String>>

Reads an optional list of string values.

Missing fields read as an empty vector so callers can treat absent arrays as the natural zero value. A present non-list field, or any non-string list item, is reported as a type mismatch.

Source

pub fn tables(&self, key: &str) -> ConfigResult<Vec<ConfigView<'a>>>

Reads an optional repeated table field as borrowed table views.

Config codecs represent [[name]] repeated tables as a list of map expressions. Missing fields read as an empty vector. A present field must be a list whose items are maps.

Trait Implementations§

Source§

impl<'a> Clone for ConfigView<'a>

Source§

fn clone(&self) -> ConfigView<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for ConfigView<'a>

Source§

impl<'a> Debug for ConfigView<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ConfigView<'a>

§

impl<'a> RefUnwindSafe for ConfigView<'a>

§

impl<'a> Send for ConfigView<'a>

§

impl<'a> Sync for ConfigView<'a>

§

impl<'a> Unpin for ConfigView<'a>

§

impl<'a> UnsafeUnpin for ConfigView<'a>

§

impl<'a> UnwindSafe for ConfigView<'a>

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.