Skip to main content

qubit_validator/report/
violation_code_error.rs

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