vortex_protocol/error/mod.rs
1/*
2 * Copyright 2025 The Dragonfly Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/// Error is the error type for the Vortex protocol.
18#[derive(thiserror::Error, Debug)]
19pub enum Error {
20 /// InvalidPacket indicates an invalid Vortex packet.
21 #[error("invalid vortex packet, cause: {0}")]
22 InvalidPacket(String),
23
24 /// InvalidLength indicates an invalid length.
25 #[error("invalid length, cause: {0}")]
26 InvalidLength(String),
27
28 /// InvalidTag indicates an invalid tag.
29 #[error("invalid tag: {0}")]
30 InvalidTag(String),
31
32 /// TryFromSliceError indicates a conversion error.
33 #[error(transparent)]
34 TryFromSliceError(#[from] std::array::TryFromSliceError),
35
36 /// Utf8Error indicates a conversion error.
37 #[error(transparent)]
38 Utf8Error(#[from] std::str::Utf8Error),
39
40 /// ParseIntError indicates a conversion error.
41 #[error(transparent)]
42 ParseIntError(#[from] std::num::ParseIntError),
43
44 /// FromUtf8Error indicates a conversion error.
45 #[error(transparent)]
46 FromUtf8Error(#[from] std::string::FromUtf8Error),
47}
48
49/// Result is the result type for the Vortex protocol.
50pub type Result<T> = std::result::Result<T, Error>;