Skip to main content

FigletError

Enum FigletError 

Source
#[non_exhaustive]
pub enum FigletError { FontNotFound { name: String, searched: Vec<PathBuf>, }, FontParse { reason: String, line: u32, }, Io(Error), WidthTooNarrow { needed: u32, given: u32, }, Internal(&'static str), }
Expand description

All fallible operations in rusty-figlet return Result<T, FigletError>.

The enum is #[non_exhaustive] (per AD-013) so additive variants in future minor releases do NOT constitute a breaking change. Downstream matches MUST include a wildcard _ arm:

use rusty_figlet::FigletError;
fn describe(err: &FigletError) -> &'static str {
    match err {
        FigletError::FontNotFound { .. } => "missing font",
        FigletError::FontParse { .. } => "bad font file",
        FigletError::Io(_) => "io error",
        FigletError::WidthTooNarrow { .. } => "width too narrow",
        FigletError::Internal(_) => "internal error",
        _ => "unknown",
    }
}

Error::source() returns Some(&io::Error) ONLY for the FigletError::Io variant; all other variants are leaf errors and return None from source(). FontParse { line } is 1-indexed and matches the convention used by upstream figlet(6) parse-error stderr messages.

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.
§

FontNotFound

The requested font name (or path) could not be located.

name is the user-supplied identifier; searched is the ordered list of paths the resolver consulted, suitable for displaying in a diagnostic message.

Fields

§name: String

Font name or path the user supplied (e.g. "slant", "./my.flf").

§searched: Vec<PathBuf>

Ordered list of paths inspected during font resolution.

§

FontParse

A .flf file failed to parse.

reason is a short human description (e.g. "bad signature", "missing endmark"); line is the 1-indexed line number at which the parser detected the problem.

Fields

§reason: String

Short human-readable description of the parse failure.

§line: u32

1-indexed line number where the parse error was detected.

§

Io(Error)

Underlying I/O failure (file read, stdin, stdout).

Error::source() returns the wrapped io::Error for this variant.

§

WidthTooNarrow

The requested width is too narrow to render the requested glyph(s).

needed is the minimum width a single glyph requires; given is the width the caller supplied.

Fields

§needed: u32

Minimum width required by the widest glyph.

§given: u32

Width supplied by the caller.

§

Internal(&'static str)

An internal invariant was violated. Indicates a bug in the library; please file an issue.

Trait Implementations§

Source§

impl Debug for FigletError

Source§

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

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

impl Display for FigletError

Source§

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

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

impl Error for FigletError

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

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 FigletError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<StrictError> for FigletError

Available on crate feature strict-compat only.
Source§

fn from(err: StrictError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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> 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 = 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 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.