You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/collation.rs
+241-5
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,10 @@
1
+
use std::convert::TryFrom;
2
+
1
3
use serde::{Deserialize,Serialize};
2
4
use typed_builder::TypedBuilder;
3
5
6
+
usecrate::error::{Error,ErrorKind};
7
+
4
8
/// A collation configuration. See the official MongoDB
5
9
/// [documentation](https://docs.mongodb.com/manual/reference/collation/) for more information on
6
10
/// each of the fields.
@@ -16,15 +20,15 @@ pub struct Collation {
16
20
17
21
/// The level of comparison to perform. Corresponds to [ICU Comparison Levels](http://userguide.icu-project.org/collation/concepts#TOC-Comparison-Levels).
18
22
#[builder(default, setter(strip_option))]
19
-
pubstrength:Option<i32>,
23
+
pubstrength:Option<CollationStrength>,
20
24
21
-
/// Whether to include case comparison when `strength` is level 1 or 2.
25
+
/// Whether to include a separate level for case differences. See [ICU Collation: CaseLevel](http://userguide.icu-project.org/collation/concepts#TOC-CaseLevel) for more information.
22
26
#[builder(default, setter(strip_option))]
23
27
pubcase_level:Option<bool>,
24
28
25
29
/// The sort order of case differences during tertiary level comparisons.
26
30
#[builder(default, setter(strip_option))]
27
-
pubcase_first:Option<String>,
31
+
pubcase_first:Option<CollationCaseFirst>,
28
32
29
33
/// Whether to compare numeric strings as numbers or strings.
30
34
#[builder(default, setter(strip_option))]
@@ -33,12 +37,12 @@ pub struct Collation {
33
37
/// Whether collation should consider whitespace and punctuation as base characters for
34
38
/// purposes of comparison.
35
39
#[builder(default, setter(strip_option))]
36
-
pubalternate:Option<String>,
40
+
pubalternate:Option<CollationAlternate>,
37
41
38
42
/// Up to which characters are considered ignorable when `alternate` is "shifted". Has no
39
43
/// effect if `alternate` is set to "non-ignorable".
40
44
#[builder(default, setter(strip_option))]
41
-
pubmax_variable:Option<String>,
45
+
pubmax_variable:Option<CollationMaxVariable>,
42
46
43
47
/// Whether to check if text require normalization and to perform it.
44
48
#[builder(default, setter(strip_option))]
@@ -48,3 +52,235 @@ pub struct Collation {
48
52
#[builder(default, setter(strip_option))]
49
53
pubbackwards:Option<bool>,
50
54
}
55
+
56
+
/// The level of comparison to perform. Corresponds to [ICU Comparison Levels](http://userguide.icu-project.org/collation/concepts#TOC-Comparison-Levels).
57
+
#[derive(Debug,Clone,Copy)]
58
+
#[non_exhaustive]
59
+
pubenumCollationStrength{
60
+
/// Typically, this is used to denote differences between base characters (for example, "a" <
61
+
/// "b").
62
+
///
63
+
/// This is also called the level-1 strength.
64
+
Primary,
65
+
66
+
/// Accents in the characters are considered secondary differences (for example, "as" < "às" <
67
+
/// "at").
68
+
///
69
+
/// This is also called the level-2 strength.
70
+
Secondary,
71
+
72
+
/// Upper and lower case differences in characters are distinguished at the tertiary level (for
73
+
/// example, "ao" < "Ao" < "aò").
74
+
///
75
+
/// This is also called the level-3 strength.
76
+
Tertiary,
77
+
78
+
/// When punctuation is ignored at level 1-3, an additional level can be used to distinguish
79
+
/// words with and without punctuation (for example, "ab" < "a-b" < "aB").
80
+
///
81
+
/// This is also called the level-4 strength.
82
+
Quaternary,
83
+
84
+
/// When all other levels are equal, the identical level is used as a tiebreaker. The Unicode
85
+
/// code point values of the NFD form of each string are compared at this level, just in
0 commit comments