1use std::fmt;
2use std::io;
3
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub enum IpcError {
8 InvalidRequest(String),
9 NotFound(String),
10 Ambiguous(String),
11 Unsupported(String),
12 Internal(String),
13}
14
15#[derive(Debug)]
16pub enum CodecError {
17 Io(io::Error),
18 Encode(postcard::Error),
19 Decode(postcard::Error),
20 FrameTooLarge(u32),
21}
22
23impl fmt::Display for CodecError {
24 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
25 match self {
26 Self::Io(e) => write!(f, "i/o error: {e}"),
27 Self::Encode(e) => write!(f, "encode error: {e}"),
28 Self::Decode(e) => write!(f, "decode error: {e}"),
29 Self::FrameTooLarge(len) => write!(f, "frame too large: {len} bytes"),
30 }
31 }
32}
33
34impl std::error::Error for CodecError {}
35
36impl From<io::Error> for CodecError {
37 fn from(value: io::Error) -> Self {
38 Self::Io(value)
39 }
40}