[][src]Struct tectonic_io_base::InputHandle

pub struct InputHandle { /* fields omitted */ }

Input handles are basically Read objects with a few extras. We don't require the standard io::Seek because we need to provide a dummy implementation for GZip streams, which we wouldn't be allowed to do because both the trait and the target struct are outside of our crate.

An important role for the InputHandle struct is computing a cryptographic digest of the input file. The driver uses this information in order to figure out if the TeX engine needs rerunning. TeX makes our life more difficult, though, since it has somewhat funky file access patterns. LaTeX file opens work by opening a file and immediately closing it, which tests whether the file exists, and then by opening it again for real. Under the hood, XeTeX reads a couple of bytes from each file upon open to sniff its encoding. So we can't just stream data from read() calls into the SHA2 computer, since we end up seeking and reading redundant data.

The current system maintains some internal state that, so far, helps us Do The Right Thing given all this. If there's a seek on the file, we give up on our digest computation. But if there's a seek back to the file beginning, we are open to the possibility of restarting the computation. But if nothing is ever read from the file, we once again give up on the computation. The ExecutionState code then has further pieces that track access to nonexistent files, which we treat as being equivalent to an existing empty file for these purposes.

Implementations

impl InputHandle[src]

pub fn new<T: 'static + InputFeatures>(
    name: &OsStr,
    inner: T,
    origin: InputOrigin
) -> InputHandle

Notable traits for InputHandle

impl Read for InputHandle
[src]

Create a new InputHandle wrapping an underlying type that implements InputFeatures.

pub fn new_read_only<T: 'static + InputFeatures>(
    name: &OsStr,
    inner: T,
    origin: InputOrigin
) -> InputHandle

Notable traits for InputHandle

impl Read for InputHandle
[src]

Create a new InputHandle in read-only mode.

pub fn name(&self) -> &OsStr[src]

Get the name associated with this handle.

pub fn origin(&self) -> InputOrigin[src]

Get the "origin" associated with this handle.

pub fn into_inner(self) -> Box<dyn InputFeatures>[src]

Consumes the object and returns the underlying readable handle that it references.

pub fn scan_remainder(&mut self) -> Result<()>[src]

Read any remaining data in the file and incorporate them into the digest. This helps the rerun detection logic work correctly in the somewhat-unusual case that a file is read then written, but only part of the file is read, not the entire thing. This seems to happen with biblatex XML state files.

pub fn into_name_digest(self) -> (OsString, Option<DigestData>)[src]

Consumes the object and returns the SHA256 sum of the content that was read. No digest is returned if there was ever a seek on the input stream, since in that case the results will not be reliable. We also return None if the stream was never read, which is another common TeX access pattern: files are opened, immediately closed, and then opened again. Finally, no digest is returned if the file is marked read-only.

pub fn getc(&mut self) -> Result<u8>[src]

Various piece of TeX want to use the libc ungetc() function a lot. It's kind of gross, but happens often enough that we provide special support for it. Here's getc() emulation that can return a previously ungetc()-ed character.

pub fn ungetc(&mut self, byte: u8) -> Result<()>[src]

Here's the ungetc() emulation.

Trait Implementations

impl InputFeatures for InputHandle[src]

impl Read for InputHandle[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.