Crate tectonic_io_base

source ·
Expand description

Tectonic’s pluggable I/O backend.

This crates defines the core traits and types used by Tectonic’s I/O subsystem, and provides implementations for common stdlib types. It provides a simplified I/O model compatible with TeX’s usage patterns, as encapsulated in the IoProvider trait. Files are exposed as InputHandle or OutputHandle structs, which add a layer of bookkeeping to allow the higher levels of Tectonic to determine when the engine needs to be re-run.


  • Default directories for per-user Tectonic files.
  • Helpers to tidy up the computation of digests in various places.
  • Tectonic I/O implementations for std::fs types.
  • Tectonic I/O implementations for types provided by flate2.
  • An “I/O stack” is an I/O provider that delegates requests to a series of sub-providers in turn.
  • Tectonic I/O trait implementations for the standard I/O streams.


  • 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.
  • A handle for Tectonic output streams.


  • What kind of source an input file ultimately came from. We keep track of this in order to be able to emit Makefile-style dependencies for input files. Right now, we only provide enough options to achieve this goal; we could add more.
  • A convenience type for file-open operations when “not found” needs to be handled specially.
  • Errors that are generic to Tectonic’s framework, but not capturable as IoErrors.


  • A hack to allow casting of Bundles to IoProviders.
  • An extension to the basic Read trait supporting additional features needed for Tectonic’s I/O system.
  • A trait for types that can read or write files needed by the TeX engine.


  • Normalize a TeX path if possible, otherwise return the original path.
  • Try to open a file on the fileystem, returning an OpenResult type allowing easy handling if the file was not found.