Files
notedeck/enostr/src/error.rs
William Casarin 672f95749a Revert "json: deserialize note ids into bytes"
This reverts commit 1ba597fc0a.
2023-07-06 17:50:20 -07:00

39 lines
962 B
Rust

use serde_json;
#[derive(Debug)]
pub enum Error {
MessageEmpty,
MessageDecodeFailed,
InvalidSignature,
Json(serde_json::Error),
Generic(String),
}
impl std::cmp::PartialEq for Error {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Error::MessageEmpty, Error::MessageEmpty) => true,
(Error::MessageDecodeFailed, Error::MessageDecodeFailed) => true,
(Error::InvalidSignature, Error::InvalidSignature) => true,
// This is slightly wrong but whatevs
(Error::Json(..), Error::Json(..)) => true,
(Error::Generic(left), Error::Generic(right)) => left == right,
_ => false,
}
}
}
impl std::cmp::Eq for Error {}
impl From<String> for Error {
fn from(s: String) -> Self {
Error::Generic(s)
}
}
impl From<serde_json::Error> for Error {
fn from(e: serde_json::Error) -> Self {
Error::Json(e)
}
}