pub enum DeserializationError {
    FileIsEmpty,
    FileHasOneByte(u8),
    InternalFileLengthIsZero,
    InternalFileLengthIsNegative(i16),
    InternalFileLengthIsTooBig(i16, usize),
    InternalFileLengthIsTooSmall(i16, usize),
    SubFileSizeIsNegative(SubFileSizes),
    HeaderLengthIsTooSmall(i16),
    InvalidCharacterRange(i16, i16),
    IncompleteSubFiles(SubFileSizes),
    TooManyExtensibleCharacters(i16),
    InconsistentSubFileSizes(SubFileSizes),
}

Variants§

§

FileIsEmpty

The TFM file is empty (i.e., 0 bytes).

Knuth’s TFToPL doesn’t handle this case explicitly. Providing an empty file to the TFtoPL always returns an error. However, the error message is non-deterministic and depends on the initial value of a specific byte of memory (tfm[0]). If that byte is greater than 127 the message for DeserializationError::InternalFileLengthIsNegative is printed; otherwise the message for DeserializationError::FileHasOneByte is printed.

§

FileHasOneByte(u8)

The TFM file consists of a single byte.

§

InternalFileLengthIsZero

The file length specified inside the TFM file is invalid because it is zero.

§

InternalFileLengthIsNegative(i16)

The file length specified inside the TFM file is invalid because it is negative.

The variant payload is the invalid length in this file.

§

InternalFileLengthIsTooBig(i16, usize)

The file length specified inside the TFM file is invalid because the file is smaller than it claims.

The variant payload is the invalid length of this file (in words) and the actual file size (in bytes). One word is 4 bytes.

§

InternalFileLengthIsTooSmall(i16, usize)

The file length specified inside the TFM file is invalid because it is too small.

TFM files must contain at least 24 bytes of data: the 16-bit file size and the 11 16-bit numbers in the sub file sizes section.

Knuth’s TFToPL doesn’t handle this case explicitly. When this buggy input is provided, a DeserializationError::SubFileSizeIsNegative error is thrown in some cases, and a DeserializationError::HeaderLengthIsTooSmall in other cases. Although the result is deterministic, there seems to be undefined behavior here because it seems to depend on the value of uninitialized memory.

§

SubFileSizeIsNegative(SubFileSizes)

One of the sub file sizes is negative.

§

HeaderLengthIsTooSmall(i16)

The header length is too small (either 0 or 1).

§

InvalidCharacterRange(i16, i16)

The character range is invalid.

This means either that the lower bound of the range (the smallest character) is not smaller than the upper bound of the range (the largest character), or the upper bound is bigger than 255.

§

IncompleteSubFiles(SubFileSizes)

The character dimension sub-files are incomplete.

This means the sub-file for either widths, heights, depths or italic corrections is empty.

§

TooManyExtensibleCharacters(i16)

There are more than 256 extensible characters.

§

InconsistentSubFileSizes(SubFileSizes)

The sub-file sizes are inconsistent.

Implementations§

source§

impl DeserializationError

source

pub fn tftopl_message(&self) -> String

Returns the error message the TFtoPL program prints for this kind of error.

source

pub fn tftopl_section(&self) -> usize

Returns the section in Knuth’s TFtoPL (version 2014) in which this error occurs.

Trait Implementations§

source§

impl Debug for DeserializationError

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq<DeserializationError> for DeserializationError

source§

fn eq(&self, other: &DeserializationError) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for DeserializationError

source§

impl StructuralEq for DeserializationError

source§

impl StructuralPartialEq for DeserializationError

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.