pub(crate) struct SectionRules<T: Keyword> {
rules: Vec<Option<TokenFmt<T>>>,
}
Expand description
Describe the rules for one section of a document.
The rules are represented as a mapping from token index to rules::TokenFmt.
Fields§
§rules: Vec<Option<TokenFmt<T>>>
A set of rules for decoding a series of tokens into a Section object. Each element of this array corresponds to the token with the corresponding index values.
When an array element is None, the corresponding keyword is not allowed in this kind section. Otherwise, the array element is a TokenFmt describing how many of the corresponding token may appear, and what they need to look like.
Implementations§
Source§impl<T: Keyword> SectionRules<T>
impl<T: Keyword> SectionRules<T>
Sourcepub(crate) fn builder() -> SectionRulesBuilder<T>
pub(crate) fn builder() -> SectionRulesBuilder<T>
Create a new builder for a SectionRules with no rules.
By default, no Keyword is allowed by this SectionRules.
Sourcefn parse_unverified<'a, I>(
&self,
tokens: I,
section: &mut Section<'a, T>,
) -> Result<()>
fn parse_unverified<'a, I>( &self, tokens: I, section: &mut Section<'a, T>, ) -> Result<()>
Parse a stream of tokens into a Section object without (fully) verifying them.
Some errors are detected early, but others only show up later when we validate more carefully.
Sourcefn validate(&self, s: &Section<'_, T>) -> Result<()>
fn validate(&self, s: &Section<'_, T>) -> Result<()>
Check whether the tokens in a section we’ve parsed conform to these rules.
Sourcefn validate_objects(&self, s: &Section<'_, T>, kwd: T) -> Result<()>
fn validate_objects(&self, s: &Section<'_, T>, kwd: T) -> Result<()>
Check all the base64-encoded objects on a given keyword.
We use this to validate objects on unrecognized items, since otherwise nothing would check that they are well-formed.
Trait Implementations§
Source§impl<T: Clone + Keyword> Clone for SectionRules<T>
impl<T: Clone + Keyword> Clone for SectionRules<T>
Source§fn clone(&self) -> SectionRules<T>
fn clone(&self) -> SectionRules<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<T> Freeze for SectionRules<T>
impl<T> RefUnwindSafe for SectionRules<T>where
T: RefUnwindSafe,
impl<T> Send for SectionRules<T>where
T: Send,
impl<T> Sync for SectionRules<T>where
T: Sync,
impl<T> Unpin for SectionRules<T>where
T: Unpin,
impl<T> UnwindSafe for SectionRules<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more