mla_titlecase/error.rs
1//! Error types for plugin and lexicon operations.
2
3/// Result type used by fallible library operations.
4pub type Result<T> = std::result::Result<T, Error>;
5
6/// Library error variants.
7#[derive(Debug, thiserror::Error)]
8#[non_exhaustive]
9pub enum Error {
10 /// The requested operation used invalid data.
11 #[error("invalid data: {0}")]
12 InvalidData(String),
13
14 /// The requested operation used an unsupported format version.
15 #[error("unsupported format version {found}; expected {expected}")]
16 UnsupportedVersion {
17 /// The version encountered in the input.
18 found: u32,
19 /// The version supported by the library.
20 expected: u32,
21 },
22
23 /// The input checksum did not match the expected value.
24 #[error("checksum mismatch: expected {expected}, got {actual}")]
25 ChecksumMismatch {
26 /// The expected checksum.
27 expected: String,
28 /// The checksum actually computed.
29 actual: String,
30 },
31
32 /// The payload kind cannot be encoded in the requested format.
33 #[error("unsupported payload kind {kind} for {format} format")]
34 UnsupportedPayload {
35 /// The payload kind name.
36 kind: &'static str,
37 /// The format name.
38 format: &'static str,
39 },
40
41 /// JSON serialization or parsing failed.
42 #[error(transparent)]
43 Json(#[from] serde_json::Error),
44
45 /// FST serialization or parsing failed.
46 #[error(transparent)]
47 Fst(#[from] fst::Error),
48
49 /// UTF-8 decoding failed.
50 #[error(transparent)]
51 Utf8(#[from] std::string::FromUtf8Error),
52
53 /// UTF-8 decoding from a borrowed slice failed.
54 #[error(transparent)]
55 StrUtf8(#[from] std::str::Utf8Error),
56
57 /// An I/O failure occurred.
58 #[error(transparent)]
59 Io(#[from] std::io::Error),
60}