diff options
| author | zirkonya <zirkonya@iridium.lan> | 2026-08-29 22:11:23 +0200 |
|---|---|---|
| committer | zirkonya <zirkonya@iridium.lan> | 2026-08-29 22:11:23 +0200 |
| commit | bf9b81e669f4ce98c8d58df5d776ae90726d7ec2 (patch) | |
| tree | e0d5bdbd8a3423f1303577ddebbfa34696d336bb /src/codec/error.rs | |
| parent | bb41e396aca01fee9f81785681fac0a79d0fd9d8 (diff) | |
Add transport layer
Diffstat (limited to 'src/codec/error.rs')
| -rw-r--r-- | src/codec/error.rs | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/src/codec/error.rs b/src/codec/error.rs index c1bd4f7..7d88d55 100644 --- a/src/codec/error.rs +++ b/src/codec/error.rs @@ -1,37 +1,24 @@ -use std::fmt::Display; +use thiserror::Error; -// TODO : better error (using thiserror) +#[derive(Debug, Error)] +pub enum CodecError { + #[error("io error: {0}")] + IoError(#[from] std::io::Error), -#[derive(Debug)] -pub enum Error { - IoError(std::io::Error), + #[error("{0}")] Custom(String), } -impl std::error::Error for Error {} +pub type Result<T> = core::result::Result<T, CodecError>; -impl Display for Error { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{self:?}") - } -} - -pub type Result<T> = core::result::Result<T, Error>; - -impl From<std::io::Error> for Error { - fn from(value: std::io::Error) -> Self { - Self::IoError(value) +impl From<&str> for CodecError { + fn from(value: &str) -> Self { + Self::Custom(value.to_string()) } } -impl From<String> for Error { +impl From<String> for CodecError { fn from(value: String) -> Self { Self::Custom(value) } } - -impl From<&str> for Error { - fn from(value: &str) -> Self { - Self::Custom(value.to_string()) - } -} |
