qubit_codec/value/value_codec_id_error.rs
1// =============================================================================
2// Copyright (c) 2026 Haixing Hu.
3//
4// SPDX-License-Identifier: Apache-2.0
5//
6// Licensed under the Apache License, Version 2.0.
7// =============================================================================
8
9//! Stable value-codec ID errors.
10
11use thiserror::Error;
12
13/// A stable value-codec ID protocol violation.
14///
15/// # Examples
16///
17/// ```
18/// use qubit_codec::ValueCodecId;
19/// use qubit_codec::ValueCodecIdError;
20///
21/// let error = ValueCodecId::try_new("").unwrap_err();
22/// assert_eq!(error, ValueCodecIdError::Empty);
23/// assert_eq!(error.to_string(), "value codec ID cannot be empty");
24/// ```
25#[derive(Clone, Copy, Debug, Eq, Error, PartialEq)]
26#[must_use]
27pub enum ValueCodecIdError {
28 /// The complete ID is empty.
29 #[error("value codec ID cannot be empty")]
30 Empty,
31 /// One dot-separated segment is empty.
32 #[error("value codec ID contains an empty segment")]
33 EmptySegment,
34 /// One segment has an invalid initial byte or character.
35 #[error("value codec ID contains an invalid segment")]
36 InvalidSegment,
37}