1// Copyright 2025 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 thiserror::Error;
67use fidl_next_codec::{DecodeError, EncodeError};
89/// Error returned by TryFrom on a strict enum if none of the members match the supplied value.
10#[derive(Debug)]
11pub struct UnknownStrictEnumMemberError(i128);
1213impl UnknownStrictEnumMemberError {
14/// Create a new error given an unknown value.
15pub fn new(unknown_value: i128) -> Self {
16Self(unknown_value)
17 }
18}
1920impl core::fmt::Display for UnknownStrictEnumMemberError {
21fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
22write!(f, "Strict enum doesn't have a member with value: {}", self.0)
23 }
24}
2526impl core::error::Error for UnknownStrictEnumMemberError {}
2728/// An encoding, decoding, or transport FIDL error.
29#[derive(Error, Debug)]
30pub enum Error<E> {
31/// A FIDL encoding error.
32#[error("encoding error: {0}")]
33Encode(#[from] EncodeError),
34/// A FIDL decoding error.
35#[error("decoding error: {0}")]
36Decode(#[from] DecodeError),
37/// A FIDL transport error.
38#[error("transport error: {0}")]
39Transport(E),
40}