1use crate::append;
6
7use thiserror::Error;
8
9#[derive(Error, Debug, PartialEq, Eq)]
10pub enum FrameWriteError {
11    #[error("Buffer is too small")]
12    BufferTooSmall,
13    #[error("Attempted to write an invalid frame: {0}")]
14    InvalidData(String),
15    #[error("Write failed: {0}")]
16    BadWrite(String),
17}
18
19impl From<append::BufferTooSmall> for FrameWriteError {
20    fn from(_error: append::BufferTooSmall) -> Self {
21        FrameWriteError::BufferTooSmall
22    }
23}
24
25impl From<zx::Status> for FrameWriteError {
26    fn from(status: zx::Status) -> Self {
27        FrameWriteError::BadWrite(status.to_string())
28    }
29}
30#[derive(Error, Debug, PartialEq, Eq)]
31#[error("Error parsing frame: {0}")]
32pub struct FrameParseError(pub(crate) String);
33
34pub type FrameParseResult<T> = Result<T, FrameParseError>;