1use runefs::Error as RuneFsError;
4use std::io;
5use thiserror::Error;
6
7pub(crate) type Result<T> = std::result::Result<T, Error>;
8
9#[derive(Error, Debug)]
11pub enum Error {
12 #[error(transparent)]
14 Io(#[from] io::Error),
15 #[error(transparent)]
16 NameHash(#[from] NameHashMismatch),
17 #[error("unknown parser error")]
18 Parse(#[from] nom::Err<()>),
19 #[error(transparent)]
20 Validate(#[from] ValidateError),
21 #[error(transparent)]
22 RuneFs(#[from] RuneFsError),
23}
24
25#[derive(Error, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
26#[error("identifier hash {hash} for name \"{name}\" not found in index {idx}")]
27pub struct NameHashMismatch {
28 pub(crate) hash: i32,
29 pub(crate) name: String,
30 pub(crate) idx: u8,
31}
32
33#[derive(Error, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
34pub enum ValidateError {
35 #[error("expected crc length of {expected} but was {actual}")]
36 InvalidLength {
37 expected: usize,
38 actual: usize,
39 },
40 #[error("mismatch crc at index {idx}, expected {internal} but was {external}")]
41 InvalidCrc {
42 idx: usize,
43 internal: u32,
44 external: u32,
45 },
46}