1// Copyright 2019 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
45use crate::append;
67use thiserror::Error;
89#[derive(Error, Debug, PartialEq, Eq)]
10pub enum FrameWriteError {
11#[error("Buffer is too small")]
12BufferTooSmall,
13#[error("Attempted to write an invalid frame: {0}")]
14InvalidData(String),
15#[error("Write failed: {0}")]
16BadWrite(String),
17}
1819impl From<append::BufferTooSmall> for FrameWriteError {
20fn from(_error: append::BufferTooSmall) -> Self {
21 FrameWriteError::BufferTooSmall
22 }
23}
2425impl From<zx::Status> for FrameWriteError {
26fn 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);
3334pub type FrameParseResult<T> = Result<T, FrameParseError>;