Skip to main content

icu_collections/codepointtrie/
error.rs

1// This file is part of ICU4X. For terms of use, please see the file
2// called LICENSE at the top level of the ICU4X source tree
3// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4
5//! Custom error type(s) for the parent module.
6
7use displaydoc::Display;
8
9/// A custom error type for [`CodePointTrie`](super::CodePointTrie).
10#[derive(Copy, Clone, Display, Debug, PartialEq)]
11#[non_exhaustive]
12pub enum Error {
13    /// Could not construct [`CodePointTrie`](super::CodePointTrie) from deserialized values
14    #[displaydoc("Could not construct CodePointTrie from deserialized values: {reason}")]
15    FromDeserialized {
16        /// Reason for inability to deserialize values.
17        reason: &'static str,
18    },
19    /// [`CodePointTrie`](super::CodePointTrie) must be constructed from data vector with at least one element
20    #[displaydoc("CodePointTrie must be constructed from data vector with at least one element")]
21    EmptyDataVector,
22    /// [`CodePointTrie`](super::CodePointTrie) must be constructed from index vector long enough to accommodate fast-path access
23    #[displaydoc(
24        "CodePointTrie must be constructed from index vector long enough to accommodate fast-path access"
25    )]
26    IndexTooShortForFastAccess,
27    /// [`CodePointTrie`](super::CodePointTrie) must be constructed from data vector long enough to accommodate fast-path access
28    #[displaydoc(
29        "CodePointTrie must be constructed from data vector long enough to accommodate fast-path access"
30    )]
31    DataTooShortForFastAccess,
32}
33
34impl core::error::Error for Error {}