#[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
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
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
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
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
impl Debug for FigletError
Source§impl Display for FigletError
impl Display for FigletError
Source§impl Error for FigletError
impl Error for FigletError
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
use the Display impl or to_string()
Source§impl From<Error> for FigletError
impl From<Error> for FigletError
Source§impl From<StrictError> for FigletError
Available on crate feature strict-compat only.
impl From<StrictError> for FigletError
strict-compat only.