pub struct Document<'de> {
pub ctx: Context<'de>,
/* private fields */
}Expand description
The result of parsing a TOML document.
Wraps the parsed Table tree and a Context that
accumulates errors.
Access values via index operators (doc["key"]) which return
MaybeItem, or use table_helper and
to for typed conversion.
§Examples
let arena = toml_spanner::Arena::new();
let doc = toml_spanner::parse("name = 'world'", &arena).unwrap();
assert_eq!(doc["name"].as_str(), Some("world"));Fields§
§ctx: Context<'de>from-toml only.Implementations§
Source§impl<'de> Document<'de>
impl<'de> Document<'de>
Source§impl<'de> Document<'de>
impl<'de> Document<'de>
Sourcepub fn table_helper<'ctx>(&'ctx mut self) -> TableHelper<'ctx, 'ctx, 'de>
Available on crate feature from-toml only.
pub fn table_helper<'ctx>(&'ctx mut self) -> TableHelper<'ctx, 'ctx, 'de>
from-toml only.Creates a TableHelper for the root table.
Typical entry point for typed extraction. Extract fields with
TableHelper::required and
TableHelper::optional, then call
TableHelper::require_empty to
reject unknown keys.
Sourcepub fn to<T: FromToml<'de>>(&mut self) -> Result<T, FromTomlError>
Available on crate feature from-toml only.
pub fn to<T: FromToml<'de>>(&mut self) -> Result<T, FromTomlError>
from-toml only.Converts the root table into a typed value T via FromToml.
§Errors
Returns FromTomlError containing all accumulated errors.
Sourcepub fn to_allowing_errors<T>(
&mut self,
) -> Result<(T, FromTomlError), FromTomlError>where
T: FromToml<'de>,
Available on crate feature from-toml only.
pub fn to_allowing_errors<T>(
&mut self,
) -> Result<(T, FromTomlError), FromTomlError>where
T: FromToml<'de>,
from-toml only.Converts the root table into a typed value T via FromToml.
returning non-fatal errors alongside.
§Errors
Returns FromTomlError containing all accumulated errors.
Sourcepub fn errors(&self) -> &[Error]
Available on crate feature from-toml only.
pub fn errors(&self) -> &[Error]
from-toml only.Returns the accumulated errors.
Sourcepub fn has_errors(&self) -> bool
Available on crate feature from-toml only.
pub fn has_errors(&self) -> bool
from-toml only.Returns true if any errors have been recorded.