Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 15 variants TtLib(String), FileIsCollection(String), TableNotFound(Tag), GlyphNotFound(String), Struct(String), Assertion(String), Value(String), Decompile { tag: Tag, source: Box<Error>, }, Compile { tag: Tag, source: Box<Error>, }, TtxParse(String), TableBusy(Tag), WrongTableType(Tag), OffsetOverflow(Box<OverflowErrorRecord>), Io(Error), Import(String),
}
Expand description

Errors from reading, writing or converting fonts.

The variants correspond to the exceptions fontTools raises, so that callers can tell them apart the same way.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

TtLib(String)

TTLibError: malformed or unsupported font data, or a misuse of the API.

§

FileIsCollection(String)

TTLibFileIsCollectionError: a collection was opened without a valid font number.

§

TableNotFound(Tag)

KeyError for a missing table.

§

GlyphNotFound(String)

KeyError for an unknown glyph name.

§

Struct(String)

struct.error: data too short to unpack, or a value that does not fit its binary field.

§

Assertion(String)

AssertionError raised by fontTools on inconsistent data.

§

Value(String)

ValueError / TypeError for invalid values.

§

Decompile

An error while decompiling a table, with the table it occurred in.

Fields

§tag: Tag

The table being decompiled.

§source: Box<Error>

The underlying error.

§

Compile

An error while compiling a table, with the table it occurred in.

Fields

§tag: Tag

The table being compiled.

§source: Box<Error>

The underlying error.

§

TtxParse(String)

TTXParseError or an XML syntax error.

§

TableBusy(Tag)

A required table is currently being decompiled, compiled or dumped, so it cannot be accessed (a circular dependency between tables).

§

WrongTableType(Tag)

A table exists but is not of the requested type (for example, it could not be decompiled and is kept as raw data).

§

OffsetOverflow(Box<OverflowErrorRecord>)

OTLOffsetOverflowError: a 16-bit offset does not fit while compiling an OpenType Layout table.

§

Io(Error)

An I/O error.

§

Import(String)

ImportError: the functionality needs an optional dependency of fontTools (one of its extras), which the Cargo feature of the same name leaves out; the message is fontTools’ (for example No module named brotli).

Implementations§

Source§

impl Error

Source

pub fn ttlib(msg: impl Into<String>) -> Self

A TTLibError with the given message.

Source

pub fn value(msg: impl Into<String>) -> Self

A ValueError with the given message.

Source

pub fn ttx(msg: impl Into<String>) -> Self

A TTX parse error with the given message.

Source

pub fn into_pen_error(self) -> Error

This error as one of fontoxide_pens, to pass it through a pen.

Source

pub fn root_cause(&self) -> &Error

The innermost error, skipping the Decompile/Compile wrappers.

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Replaced by Error::source.
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Forget for Error

§

impl Freeze for Error

§

impl Move for Error

§

impl Send for Error
where RawVecInner: Send, BoxRaw<Error>: Send, BoxRaw<OverflowErrorRecord>: Send, Repr: Send,

§

impl Sync for Error
where RawVecInner: Sync, BoxRaw<Error>: Sync, BoxRaw<OverflowErrorRecord>: Sync, Repr: Sync,

§

impl Unpin for Error
where *const u8 is !null: Unpin, Box<Error>: Unpin, Box<OverflowErrorRecord>: Unpin, *const () is !null: Unpin, &'static SimpleMessage: Unpin, *const Custom is !null: Unpin,

§

impl UnsafeUnpin for Error

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

self as &dyn Any.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

self as &mut dyn Any.
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.