pub enum Error {
InvalidData(String),
InvalidOption(String),
Unimplemented(&'static str),
Backend(String),
}Expand description
Errors that can be returned by the encoder or renderer.
Error implements std::error::Error and std::fmt::Display, so it
integrates with ?, anyhow, and thiserror like any other library
error.
§Example
use bwipp::{render_svg, Options, Symbology, Error};
let err = render_svg(Symbology::Ean13, "abc", &Options::default()).unwrap_err();
// The Display impl prepends a kind-specific prefix:
assert!(err.to_string().starts_with("invalid data:"));
// Pattern-match for programmatic recovery:
assert!(matches!(err, Error::InvalidData(_)));Variants§
InvalidData(String)
The input data is not valid for the requested symbology (e.g. wrong length, illegal character, bad check digit).
InvalidOption(String)
An option value is out of range or refers to an unknown setting.
Unimplemented(&'static str)
The symbology requested is recognized but the requested option / variant lies outside this Rust port’s scope (e.g. BWIPP feature that the port has consciously deferred).
Status note. As of the current release, no code path in the
crate actually returns this variant — the catalog is
169 verified / 0 partial (see
PORT_STATUS.md),
and the BWIPP opt-in knobs that are deferred (e.g. POSICODE
parsefnc, Code 16K sam, Code One eci/version,
Ultracode rev=1/raw=true/link1) are surfaced via
Error::InvalidData / Error::InvalidOption with a tagged
message rather than via this variant. The variant is kept in
the public API as a reserved slot for future semantic
migration (callers who want to distinguish “input invalid” from
“input valid but encoder lacks support”) and removing it would
be a breaking change. Match on it defensively if you care, but
don’t expect to see it fire today.
Backend(String)
A backing crate (e.g. qrcode, datamatrix) reported an error.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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
use the Display impl or to_string()