1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Copyright 2026 db-collation contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! # db-collation
//!
//! Offline, exact string comparison under an **explicitly identified database
//! collation and version**.
//!
//! This crate exists for one purpose: reproduce the *exact* ordering semantics
//! of a source database's collation locally, without talking to that database.
//! It is a pure function of a [`Collation`] description and the input bytes. It
//! opens no sockets, holds no drivers, and never issues a query.
//!
//! ## Guarantees and non-guarantees
//!
//! - **Exact or refused.** For a supported configuration, [`Collation::compare`]
//! matches the source database's comparison operator exactly (validated by the
//! differential harness in `harness/`). For anything not explicitly modelled,
//! construction returns [`Error::Unsupported`] and the caller should fall back
//! to comparing on the source database. A *supported* configuration can still
//! reject an individual input that exceeds a documented source limit (e.g.
//! Oracle's 2000-byte UCA sort key); that is [`Error::InputLimit`], and the
//! caller falls back for that input only.
//! - **No approximation.** Selecting the same locale name is *not* sufficient:
//! ICU data versions change ordering (e.g. `あ` vs `U+11DB0` reversed between
//! ICU 76 and 78), and `MySQL` collations differ by UCA version, tailoring and
//! padding. This crate therefore gates on version, not on names alone.
//! - **Deterministic tie-break.** `PostgreSQL` deterministic collations break ICU
//! equality ties with a bytewise comparison (shorter string first). That is
//! reproduced here; nondeterministic collations intentionally do not.
//!
//! ## Supported configurations
//!
//! See [`Collation`] and the crate `README` for the current matrix.
//!
//! # Examples
//!
//! ```
//! use db_collation::{Collation, Result};
//! use std::cmp::Ordering;
//!
//! fn main() -> Result<()> {
//! // Bytewise comparison is always available.
//! assert_eq!(Collation::binary().compare("a", "b")?, Ordering::Less);
//!
//! // Unsupported configurations fail closed, so the caller can fall back.
//! assert!(Collation::from_mysql_name_unspecified_version("utf8mb4_general_ci").is_err());
//! Ok(())
//! }
//! ```
//!
//! With the `mysql-uca` feature (enabled by default):
//!
//! ```
//! # #[cfg(feature = "mysql-uca")] {
//! use db_collation::{Collation, Result};
//! use std::cmp::Ordering;
//!
//! fn main() -> Result<()> {
//! let c = Collation::mysql_0900_ai_ci();
//! assert_eq!(c.compare("a", "A")?, Ordering::Equal);
//! Ok(())
//! }
//! # }
//! ```
pub use ;
pub use ;
pub use ;