pub struct OwnedTable { /* private fields */ }Expand description
A self-contained TOML table that owns its backing storage.
The table-specific counterpart of OwnedItem. The inner value
is always a table, so table() is infallible.
§Flattening
FromFlattened is not provided because
flatten_any is more performant
than direct implementation could be, due to current trait definition.
ⓘ
use toml_spanner::Toml;
use toml_spanner::helper::flatten_any;
#[derive(Toml)]
#[toml(Toml)]
struct Config {
name: String,
#[toml(flatten, with = flatten_any)]
extra: OwnedTable,
}§Examples
use toml_spanner::OwnedTable;
let owned: OwnedTable = toml_spanner::from_str("
host = 'localhost'
port = 8080
").unwrap();
assert_eq!(owned.get("host").unwrap().as_str(), Some("localhost"));
assert_eq!(owned.len(), 2);Implementations§
Source§impl OwnedTable
impl OwnedTable
Sourcepub fn span(&self) -> Span
pub fn span(&self) -> Span
Returns the source span, or 0..0 if this table was constructed
programmatically (format-hints mode).
Sourcepub fn get_key_value<'a>(
&'a self,
name: &str,
) -> Option<(&'a Key<'a>, &'a Item<'a>)>
pub fn get_key_value<'a>( &'a self, name: &str, ) -> Option<(&'a Key<'a>, &'a Item<'a>)>
Returns references to both key and value for name.
Sourcepub fn get<'a>(&'a self, name: &str) -> Option<&'a Item<'a>>
pub fn get<'a>(&'a self, name: &str) -> Option<&'a Item<'a>>
Returns a reference to the value for name.
Sourcepub fn contains_key(&self, name: &str) -> bool
pub fn contains_key(&self, name: &str) -> bool
Returns true if the table contains the key.
Sourcepub fn iter<'a>(&'a self) -> Iter<'a, (Key<'a>, Item<'a>)>
pub fn iter<'a>(&'a self) -> Iter<'a, (Key<'a>, Item<'a>)>
Returns an iterator over all entries (key-value pairs).
Sourcepub fn style(&self) -> TableStyle
pub fn style(&self) -> TableStyle
Returns the kind of this table (implicit, dotted, header, or inline).
Trait Implementations§
Source§impl Clone for OwnedTable
impl Clone for OwnedTable
Source§impl Debug for OwnedTable
impl Debug for OwnedTable
Source§impl From<&Table<'_>> for OwnedTable
impl From<&Table<'_>> for OwnedTable
Source§impl<'a> FromToml<'a> for OwnedTable
Available on crate feature from-toml only.
impl<'a> FromToml<'a> for OwnedTable
Available on crate feature
from-toml only.Source§impl<'a> IntoIterator for &'a OwnedTable
impl<'a> IntoIterator for &'a OwnedTable
Source§impl PartialEq for OwnedTable
impl PartialEq for OwnedTable
Source§impl ToFlattened for OwnedTable
Available on crate feature to-toml only.
impl ToFlattened for OwnedTable
Available on crate feature
to-toml only.Source§fn to_flattened<'a>(
&'a self,
arena: &'a Arena,
table: &mut Table<'a>,
) -> Result<(), ToTomlError>
fn to_flattened<'a>( &'a self, arena: &'a Arena, table: &mut Table<'a>, ) -> Result<(), ToTomlError>
Inserts this value’s entries directly into an existing table. Read more
Source§impl ToToml for OwnedTable
Available on crate feature to-toml only.
impl ToToml for OwnedTable
Available on crate feature
to-toml only.Source§fn to_optional_toml<'a>(
&'a self,
arena: &'a Arena,
) -> Result<Option<Item<'a>>, ToTomlError>
fn to_optional_toml<'a>( &'a self, arena: &'a Arena, ) -> Result<Option<Item<'a>>, ToTomlError>
impl Send for OwnedTable
impl Sync for OwnedTable
Auto Trait Implementations§
impl Freeze for OwnedTable
impl RefUnwindSafe for OwnedTable
impl Unpin for OwnedTable
impl UnsafeUnpin for OwnedTable
impl UnwindSafe for OwnedTable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more