pub trait NetdocParseable: Sized {
// Required methods
fn doctype_for_error() -> &'static str;
fn is_intro_item_keyword(kw: KeywordRef<'_>) -> bool;
fn from_items(
input: &mut ItemStream<'_>,
stop_at: StopAt<impl StopPredicate>,
) -> Result<Self, ErrorProblem>;
}
parse2
only.Expand description
A document or section that can be parsed
Normally derived.
Required Methods§
Sourcefn doctype_for_error() -> &'static str
fn doctype_for_error() -> &'static str
Document type for errors, normally its intro keyword
Sourcefn is_intro_item_keyword(kw: KeywordRef<'_>) -> bool
fn is_intro_item_keyword(kw: KeywordRef<'_>) -> bool
Is Keyword
an intro Item Keyword for this kind of document?
This is used with 1-keyword lookahead, to allow us to push or pop the parsing state into or out of a sub-document.
For signatures sections, this should report every recognised keyword.
Sourcefn from_items(
input: &mut ItemStream<'_>,
stop_at: StopAt<impl StopPredicate>,
) -> Result<Self, ErrorProblem>
fn from_items( input: &mut ItemStream<'_>, stop_at: StopAt<impl StopPredicate>, ) -> Result<Self, ErrorProblem>
Parse the document from a stream of Items
Should stop before reading any keyword matching stop_at
.
(Except, right at the start.)
Should also stop before reading a 2nd intro keyword, so that successive calls to this function can parse successive sub-documents of this kind.
Otherwise, should continue until EOF.
Must check whether the first item is this document’s is_intro_item_keyword
,
and error if not.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.