quic_reverse_control/
error.rs

1// Copyright 2024-2026 Farlight Networks, LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Error types for the control protocol.
16
17use thiserror::Error;
18
19/// Errors that can occur during control protocol operations.
20#[derive(Debug, Error)]
21pub enum ControlError {
22    /// Frame exceeds the maximum allowed size.
23    #[error("frame size {size} exceeds maximum {max}", max = crate::MAX_FRAME_SIZE)]
24    FrameTooLarge {
25        /// The actual frame size.
26        size: usize,
27    },
28
29    /// Unexpected end of input while reading a frame.
30    #[error("unexpected end of input: expected {expected} bytes, got {actual}")]
31    UnexpectedEof {
32        /// Expected number of bytes.
33        expected: usize,
34        /// Actual number of bytes available.
35        actual: usize,
36    },
37
38    /// Codec error during serialization or deserialization.
39    #[error("codec error: {0}")]
40    Codec(#[from] crate::CodecError),
41
42    /// I/O error during read or write operations.
43    #[error("I/O error: {0}")]
44    Io(#[from] std::io::Error),
45
46    /// Invalid protocol message.
47    #[error("invalid message: {0}")]
48    InvalidMessage(String),
49
50    /// Protocol version mismatch.
51    #[error("unsupported protocol version: {0}")]
52    UnsupportedVersion(u16),
53}