[−][src]Struct tectonic_io_base::InputHandle
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]
name: &OsStr,
inner: T,
origin: InputOrigin
) -> InputHandleⓘ
Notable traits for InputHandle
impl Read for InputHandle
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]
name: &OsStr,
inner: T,
origin: InputOrigin
) -> InputHandleⓘ
Notable traits for InputHandle
impl Read for InputHandle
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]
pub fn get_size(&mut self) -> Result<usize>
[src]
pub fn get_unix_mtime(&mut self) -> Result<Option<i64>>
[src]
pub fn try_seek(&mut self, pos: SeekFrom) -> Result<u64>
[src]
impl Read for InputHandle
[src]
pub fn read(&mut self, buf: &mut [u8]) -> Result<usize>
[src]
pub fn read_vectored(
&mut self,
bufs: &mut [IoSliceMut<'_>]
) -> Result<usize, Error>
1.36.0[src]
&mut self,
bufs: &mut [IoSliceMut<'_>]
) -> Result<usize, Error>
pub fn is_read_vectored(&self) -> bool
[src]
pub unsafe fn initializer(&self) -> Initializer
[src]
pub fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
1.0.0[src]
pub fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
pub fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0[src]
pub fn by_ref(&mut self) -> &mut Self
1.0.0[src]
pub fn bytes(self) -> Bytes<Self>
1.0.0[src]
pub fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0[src]
R: Read,
pub fn take(self, limit: u64) -> Take<Self>
1.0.0[src]
Auto Trait Implementations
impl !RefUnwindSafe for InputHandle
[src]
impl !Send for InputHandle
[src]
impl !Sync for InputHandle
[src]
impl Unpin for InputHandle
[src]
impl !UnwindSafe for InputHandle
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,