vector_config/
errors.rs

1#[derive(Debug)]
2pub enum BoundDirection {
3    /// Minimum bound.
4    Minimum,
5
6    /// Maximum bound.
7    Maximum,
8}
9
10/// Schema generation error.
11#[derive(Debug)]
12pub enum GenerateError {
13    /// An invalid type was encountered during schema generation.
14    ///
15    /// This typically means that the type cannot ever be represented correctly in a generated
16    /// schema, and so has been hard-coded to always fail during schema generation.
17    ///
18    /// An example of such an implementation would be the unit type.
19    InvalidType,
20
21    /// A numeric bound, specified in a validation attribute, is invalid for the underlying type.
22    IncompatibleNumericBounds {
23        /// The name of the numeric type. (e.g. `u64`)
24        numeric_type: &'static str,
25
26        /// The bound direction that was exceeded.
27        bound_direction: BoundDirection,
28
29        /// The value of the mechanical bound on the underlying type.
30        ///
31        /// This is the inherent limit, such as a 8-bit integer only being able to go as high as
32        /// 2^8.
33        mechanical_bound: f64,
34
35        /// The value of the specified bound.
36        ///
37        /// This is the value specified in the validation attribute itself.
38        specified_bound: f64,
39    },
40
41    /// A type that is not string-like was specified as the key type for a map.
42    ///
43    /// As maps resolve to the equivalent of a JSON object, which requires strings for properties
44    /// (i.e. the key), we can only allow types to be used as the key of a map when their schema
45    /// maps to a plain string.
46    MapKeyNotStringLike {
47        /// The name of the key type. (e.g. `bool`)
48        key_type: &'static str,
49
50        /// The name of the map type. (e.g. `HashMap<bool, String>`)
51        ///
52        /// This is primarily for diagnostic purposes, to determine what map usage is actually
53        /// responsible for the error. As the error occurs at runtime, we have limited information
54        /// to point the caller directly to the file/line where the misusage is occurring, other
55        /// than the type name itself.
56        map_type: &'static str,
57    },
58
59    /// A type tried to modify a schema to be optional, but provided an invalid schema.
60    ///
61    /// In order to make a schema "optional", which implies allowing it to match `null`, it must not
62    /// be a schema reference and it must already have an instance type, or types, defined.
63    InvalidOptionalSchema,
64}