fidl_next_codec/encode/
error.rs

1// Copyright 2024 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.
4
5use thiserror::Error;
6
7/// Errors that can be produced while encoding FIDL messages.
8#[derive(Error, Debug)]
9pub enum EncodeError {
10    /// A required handle was invalid.
11    #[error("required handle was invalid")]
12    InvalidRequiredHandle,
13
14    /// An encoded union had an unknown ordinal
15    #[error("cannot encode unknown union ordinal of {0}")]
16    UnknownUnionOrdinal(usize),
17
18    /// Attempted to encode a value larger than 4 bytes in an inline envelope
19    #[error("cannot encode a {0}-byte value in a 4-byte inline envelope")]
20    ExpectedInline(usize),
21
22    /// Attempted to encode a driver handle with an encoder that does not support them.
23    #[error("cannot encode driver handles with this encoder")]
24    DriverHandlesUnsupported,
25}