1use crate::{
6 coding::{DecodeError, EncodeError},
7 version::Version,
8};
9
10#[derive(Debug)]
12#[non_exhaustive]
13pub enum Error {
14 Io(std::io::Error),
16
17 InvalidVersion(Option<Version>),
19
20 Encode(EncodeError),
22
23 Decode(DecodeError),
25
26 Compress,
28
29 Decompress,
31 }
35
36impl std::fmt::Display for Error {
37 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
38 write!(f, "ValueLogError: {self:?}")
39 }
40}
41
42impl std::error::Error for Error {}
43
44impl From<std::io::Error> for Error {
45 fn from(value: std::io::Error) -> Self {
46 Self::Io(value)
47 }
48}
49
50impl From<EncodeError> for Error {
51 fn from(value: EncodeError) -> Self {
52 Self::Encode(value)
53 }
54}
55
56impl From<DecodeError> for Error {
57 fn from(value: DecodeError) -> Self {
58 Self::Decode(value)
59 }
60}
61
62pub type Result<T> = std::result::Result<T, Error>;