Enum tfm::format::DeserializationError
source · 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
impl DeserializationError
sourcepub fn tftopl_message(&self) -> String
pub fn tftopl_message(&self) -> String
Returns the error message the TFtoPL program prints for this kind of error.
sourcepub fn tftopl_section(&self) -> usize
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
impl Debug for DeserializationError
source§impl Display for DeserializationError
impl Display for DeserializationError
source§impl Error for DeserializationError
impl Error for DeserializationError
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
source§impl PartialEq for DeserializationError
impl PartialEq for DeserializationError
impl Eq for DeserializationError
impl StructuralPartialEq for DeserializationError
Auto Trait Implementations§
impl Freeze for DeserializationError
impl RefUnwindSafe for DeserializationError
impl Send for DeserializationError
impl Sync for DeserializationError
impl Unpin for DeserializationError
impl UnwindSafe for DeserializationError
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the foreground set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red()
and
green()
, which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg()
:
use yansi::{Paint, Color};
painted.fg(Color::White);
Set foreground color to white using white()
.
use yansi::Paint;
painted.white();
§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the background set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red()
and
on_green()
, which have the same functionality but
are pithier.
§Example
Set background color to red using fg()
:
use yansi::{Paint, Color};
painted.bg(Color::Red);
Set background color to red using on_red()
.
use yansi::Paint;
painted.on_red();
§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute
] value
.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold()
and
underline()
, which have the same functionality
but are pithier.
§Example
Make text bold using attr()
:
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);
Make text bold using using bold()
.
use yansi::Paint;
painted.bold();
§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi
[Quirk
] value
.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask()
and
wrap()
, which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk()
:
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);
Enable wrapping using wrap()
.
use yansi::Paint;
painted.wrap();
§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition
] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted
only when both stdout
and stderr
are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);