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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/// Selects the codec algorithm family for encoding and reconstruction.
///
/// - [`Classic`](CodecFamily::Classic): Standard Reed-Solomon over GF(2^8) using
/// Vandermonde/Cauchy matrix multiplication. Supports all shard counts up to
/// `Field::ORDER`, incremental `update`, and `encode_single`.
///
/// - [`LeopardGF8`](CodecFamily::LeopardGF8): FFT-based Leopard codec over GF(2^8).
/// Uses Fermat-number FFT with Forney syndrome decoding. Requires shard lengths
/// that are multiples of 64 bytes. Does **not** support `encode_single` or `update`.
/// Supports up to 256 total shards (data + parity).
///
/// - [`LeopardGF16`](CodecFamily::LeopardGF16): FFT-based Leopard codec over GF(2^16).
/// Supports up to 65536 total shards (data + parity).
/// Controls optional automatic selection of a Leopard codec when the requested
/// [`CodecFamily`] is [`Classic`](CodecFamily::Classic).
///
/// Auto-selection only takes effect on a byte-oriented field (where
/// `size_of::<Field::Elem>() == 1`, i.e. the GF(2^8) field the Leopard codecs
/// are built on); on any other field the mode is ignored and the codec stays
/// Classic. When the caller sets an explicit non-Classic `codec_family`, this
/// mode is likewise ignored — the explicit family wins.
///
/// The resolution, as a function of `total = data + parity` shards, mirrors the
/// klauspost/reedsolomon `New()` behaviour:
///
/// | `total` | [`AsNeeded`](LeopardMode::AsNeeded) | [`PreferLeopard`](LeopardMode::PreferLeopard) | [`PreferGF16`](LeopardMode::PreferGF16) |
/// |---------|-----------|---------------|------------|
/// | ≤ 256 | Classic | LeopardGF8¹ | LeopardGF16 |
/// | 257..=65536 | LeopardGF16 | LeopardGF16 | LeopardGF16 |
///
/// ¹ [`PreferLeopard`](LeopardMode::PreferLeopard) selects [`LeopardGF8`](CodecFamily::LeopardGF8)
/// only when `total ≤ 256` **and** `parity ≤ 128`; otherwise it falls back to
/// [`LeopardGF16`](CodecFamily::LeopardGF16).
/// Selects the encoding matrix construction strategy for [`CodecFamily::Classic`].
///
/// This option is ignored for Leopard families (they use FFT-based encoding).
///
/// - [`Vandermonde`](MatrixMode::Vandermonde): Standard Vandermonde matrix.
/// - [`Cauchy`](MatrixMode::Cauchy): Cauchy matrix construction.
/// - [`JerasureLike`](MatrixMode::JerasureLike): Jerasure-compatible matrix layout.
/// - [`Custom`](MatrixMode::Custom): User-supplied matrix via
/// [`ReedSolomon::with_custom_matrix`](crate::ReedSolomon::with_custom_matrix).
/// Configuration options for constructing a [`ReedSolomon`](crate::ReedSolomon) codec.
///
/// Use `CodecOptions::default()` for sensible defaults, or the builder methods:
///
/// ```ignore
/// use rustfs_erasure_codec::core::{CodecOptions, CodecFamily};
///
/// let opts = CodecOptions::builder()
/// .codec_family(CodecFamily::LeopardGF8)
/// .fast_one_parity(true)
/// .build();
/// ```
///
/// `CodecOptions` is `#[non_exhaustive]`: construct it from
/// [`CodecOptions::default()`] (optionally with `..Default::default()` in a
/// struct-update expression) or via the [`builder`](CodecOptions::builder), not
/// with an exhaustive struct literal. This lets future fields be added without a
/// breaking change.
/// Builder for [`CodecOptions`].
///
/// Created via [`CodecOptions::builder()`]. All methods chain; call [`build()`](CodecOptionsBuilder::build) to obtain the final `CodecOptions`.