qubit_argument/argument/constraint/length_constraint.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//! Relationships used by string and collection length constraints.
9
10/// A numeric relationship required of a measured string or collection length.
11///
12/// [`LengthMetric`](super::LengthMetric) identifies the measurement unit in a
13/// structured validation error.
14#[derive(Debug, Clone, PartialEq, Eq)]
15pub enum LengthConstraint {
16 /// Requires exactly the specified length.
17 Exact(usize),
18 /// Requires at least the specified length.
19 AtLeast(usize),
20 /// Requires at most the specified length.
21 AtMost(usize),
22 /// Requires a length between `min` and `max`, inclusive.
23 InRange {
24 /// The inclusive minimum length.
25 min: usize,
26 /// The inclusive maximum length.
27 max: usize,
28 },
29}