pub struct Reader<'r> {
pub problems: Vec<Problem>,
pub refs: Vec<Found<Ref>>,
pub tags: Vec<Found<Ref>>,
pub resources: Vec<Found<Res>>,
/* private fields */
}Expand description
The state of reading a value: where it is, the problems so far, and the references met (for the build to check against the content there is).
Fields§
§problems: Vec<Problem>§refs: Vec<Found<Ref>>§resources: Vec<Found<Res>>Implementations§
Source§impl<'r> Reader<'r>
impl<'r> Reader<'r>
pub fn new() -> Self
Sourcepub fn with_resolver(resolver: &'r mut dyn Resolve) -> Self
pub fn with_resolver(resolver: &'r mut dyn Resolve) -> Self
A reader handing references and texts to resolver.
Sourcepub fn resolve_ref(&mut self, r: &Ref) -> Option<String>
pub fn resolve_ref(&mut self, r: &Ref) -> Option<String>
r resolved (a problem if it’s wrong); its id without a resolver.
Sourcepub fn resolve_text(&mut self, t: &Text) -> Option<String>
pub fn resolve_text(&mut self, t: &Text) -> Option<String>
t resolved (a problem if it’s wrong).
Sourcepub fn take_text(&mut self, t: Text) -> Option<String>
pub fn take_text(&mut self, t: Text) -> Option<String>
Reader::resolve_text, taking t: without a resolver its words
move into the result instead of being copied.
Sourcepub fn take_ref(&mut self, r: Ref) -> Option<String>
pub fn take_ref(&mut self, r: Ref) -> Option<String>
Reader::resolve_ref, taking r: without a resolver the id moves.
Sourcepub fn keeps_found(&self) -> bool
pub fn keeps_found(&self) -> bool
Whether references are kept for the caller (read_value doesn’t).
Sourcepub fn resolves(&self) -> bool
pub fn resolves(&self) -> bool
Whether references and texts go through a resolver (else kept as written).
Sourcepub fn words(&mut self, r: &Res) -> Option<String>
pub fn words(&mut self, r: &Res) -> Option<String>
The words of .yres text r, if the resolver knows them.
Sourcepub fn problem(&mut self, message: impl Into<String>)
pub fn problem(&mut self, message: impl Into<String>)
Reports a problem with the value being read.
pub fn note_ref(&mut self, r: Ref)
pub fn note_tag(&mut self, r: Ref)
pub fn note_res(&mut self, r: Res)
Sourcepub fn map<'v>(&mut self, v: &ValueRef<'v>) -> Option<MapRef<'v>>
pub fn map<'v>(&mut self, v: &ValueRef<'v>) -> Option<MapRef<'v>>
v as an object, or a problem.
Sourcepub fn unknown_keys(&mut self, map: MapRef<'_>, known: &[&str])
pub fn unknown_keys(&mut self, map: MapRef<'_>, known: &[&str])
Reports keys of map that aren’t known (nor metadata, nor allowed by an enclosing enum).
Sourcepub fn unknown_name(&mut self, name: &str, known: &[&str])
pub fn unknown_name(&mut self, name: &str, known: &[&str])
Reports a name that isn’t one of known (an enum’s variant).
Sourcepub fn field<T: Schema>(
&mut self,
map: MapRef<'_>,
key: &'static str,
) -> Option<T>
pub fn field<T: Schema>( &mut self, map: MapRef<'_>, key: &'static str, ) -> Option<T>
Field key of map: read, or its absent value, or a problem.
Sourcepub fn field_or<T: Schema>(
&mut self,
map: MapRef<'_>,
key: &'static str,
default: impl FnOnce() -> T,
) -> Option<T>
pub fn field_or<T: Schema>( &mut self, map: MapRef<'_>, key: &'static str, default: impl FnOnce() -> T, ) -> Option<T>
Field key of map, default() when it isn’t there.
Sourcepub fn field_with<W: With<F>, F>(
&mut self,
map: MapRef<'_>,
key: &'static str,
) -> Option<F>
pub fn field_with<W: With<F>, F>( &mut self, map: MapRef<'_>, key: &'static str, ) -> Option<F>
Field key of map through codec W.
Sourcepub fn field_or_with<W: With<F>, F>(
&mut self,
map: MapRef<'_>,
key: &'static str,
default: impl FnOnce() -> F,
) -> Option<F>
pub fn field_or_with<W: With<F>, F>( &mut self, map: MapRef<'_>, key: &'static str, default: impl FnOnce() -> F, ) -> Option<F>
Field key of map through codec W, default() when it isn’t there.
Sourcepub fn with_allowed<T>(
&mut self,
key: &'static str,
f: impl FnOnce(&mut Self) -> T,
) -> T
pub fn with_allowed<T>( &mut self, key: &'static str, f: impl FnOnce(&mut Self) -> T, ) -> T
Reads v as T with key allowed in it — the tag of the enum variant T is.
Sourcepub fn with_allowed_all<T>(
&mut self,
keys: &[&'static str],
f: impl FnOnce(&mut Self) -> T,
) -> T
pub fn with_allowed_all<T>( &mut self, keys: &[&'static str], f: impl FnOnce(&mut Self) -> T, ) -> T
Reads with every one of keys allowed (the fields of a struct read
from the same object — see read_both).