pub struct StreamingParser { /* private fields */ }Expand description
An incremental Turtle parser that accepts chunks of text.
Implementations§
Source§impl StreamingParser
impl StreamingParser
Sourcepub fn feed(
&mut self,
chunk: &str,
) -> Result<Vec<ParsedTriple>, StreamParseError>
pub fn feed( &mut self, chunk: &str, ) -> Result<Vec<ParsedTriple>, StreamParseError>
Feed a chunk of Turtle text, returning all complete triples parsed.
Sourcepub fn flush(&mut self) -> Result<Vec<ParsedTriple>, StreamParseError>
pub fn flush(&mut self) -> Result<Vec<ParsedTriple>, StreamParseError>
Flush any remaining buffered content, returning any remaining triples.
parse_buffer() (invoked by every feed() call) only ever leaves the
internal buffer non-empty in two cases: it is waiting for more input
to complete the statement currently being parsed, or it is genuinely
empty — any statement that already parses cleanly is consumed and
removed from the buffer immediately, and any outright syntax error is
already surfaced as an Err from feed() itself. Therefore, if any
non-whitespace, non-comment content remains in the buffer once the
caller declares the stream finished, that content is by definition an
incomplete, truncated statement. Per this project’s fail-loud
contract, that must be reported as an error rather than silently
discarded as an empty, successful result.
Sourcepub fn triples_parsed(&self) -> u64
pub fn triples_parsed(&self) -> u64
Return total triples parsed so far.
Sourcepub fn set_base(&mut self, base: impl Into<String>)
pub fn set_base(&mut self, base: impl Into<String>)
Set the base IRI for relative IRI resolution.
Sourcepub fn parse_complete(
input: &str,
) -> Result<Vec<ParsedTriple>, StreamParseError>
pub fn parse_complete( input: &str, ) -> Result<Vec<ParsedTriple>, StreamParseError>
Parse a complete Turtle document in one call.
Sourcepub fn expand_prefix(&self, prefixed: &str) -> Result<String, StreamParseError>
pub fn expand_prefix(&self, prefixed: &str) -> Result<String, StreamParseError>
Expand a prefixed name to a full IRI using current prefix map.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StreamingParser
impl RefUnwindSafe for StreamingParser
impl Send for StreamingParser
impl Sync for StreamingParser
impl Unpin for StreamingParser
impl UnsafeUnpin for StreamingParser
impl UnwindSafe for StreamingParser
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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