Struct tectonic_xdv::XdvParser
source · [−]pub struct XdvParser<T: XdvEvents> { /* private fields */ }
Expand description
State for parsing an XDV file.
Implementations
sourceimpl<T: XdvEvents> XdvParser<T>
impl<T: XdvEvents> XdvParser<T>
sourcepub fn new(events: T) -> Self
pub fn new(events: T) -> Self
Create a new XDV/SPX parser.
Methods implemented by events will be called as various items are encountered in the file.
sourcepub fn process<R: Read>(stream: R, events: T) -> Result<(T, u64), T::Error> where
T::Error: From<IoError>,
pub fn process<R: Read>(stream: R, events: T) -> Result<(T, u64), T::Error> where
T::Error: From<IoError>,
Parse an entire XDV/SPX stream.
Returns the input “events” variable and the number of bytes that were processed.
Because the io::Read
trait is used, the event result type must
implement From<io::Error>
as well as From<XdvError>
.
sourcepub fn process_with_seeks<R: Read + Seek>(
stream: R,
events: T
) -> Result<T, T::Error> where
T::Error: From<IoError>,
pub fn process_with_seeks<R: Read + Seek>(
stream: R,
events: T
) -> Result<T, T::Error> where
T::Error: From<IoError>,
Parse a XDV/SPX stream looking at the postamble first.
Unlike Self::process
, this method relies on the input being
seekable, and starts by processing the expected “postamble” structure of
the file which provides summary information about the stream contents.
Returns the input “events” variable.
Because traits from std::io
are used, the event result type must
implement From<std::io::Error>
as well as From<XdvError>
.
sourcepub fn parse(&mut self, chunk: &[u8]) -> Result<(usize, bool), T::Error>
pub fn parse(&mut self, chunk: &[u8]) -> Result<(usize, bool), T::Error>
Parse the next chunk of XDV data.
Returns the number of bytes consumed from the input buffer, and whether the driver should continue. If the number of bytes is not the same as the buffer size, some of the existing bytes must be re-fed to the parser. If the returned value is 0, you need a bigger buffer in order to be able to parse the next directive.
sourcepub fn current_offset(&self) -> u64
pub fn current_offset(&self) -> u64
Get the current byte offset of the parsing.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for XdvParser<T> where
T: RefUnwindSafe,
impl<T> Send for XdvParser<T> where
T: Send,
impl<T> Sync for XdvParser<T> where
T: Sync,
impl<T> Unpin for XdvParser<T> where
T: Unpin,
impl<T> UnwindSafe for XdvParser<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more