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
/// Sample size configuration for sniffing.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SampleSize {
/// Sample a specific number of records.
Records(usize),
/// Sample a specific number of bytes.
Bytes(usize),
/// Read the entire file.
///
/// # Warning
///
/// This loads the entire file into memory. For large files (e.g., >100 MB), prefer
/// [`SampleSize::Bytes`] with a reasonable limit to avoid excessive memory usage.
All,
}
impl Default for SampleSize {
fn default() -> Self {
// Default to 100 records which is reasonable for most files
SampleSize::Records(100)
}
}
impl SampleSize {
/// Returns the number of records to sample, or None for All.
pub fn records(&self) -> Option<usize> {
match self {
SampleSize::Records(n) => Some(*n),
_ => None,
}
}
/// Returns the number of bytes to sample, or None for other modes.
pub fn bytes(&self) -> Option<usize> {
match self {
SampleSize::Bytes(n) => Some(*n),
_ => None,
}
}
}
/// Date format preference for ambiguous date parsing.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum DatePreference {
/// Day-Month-Year format (e.g., 31/12/2023).
DmyFormat,
/// Month-Day-Year format (e.g., 12/31/2023).
#[default]
MdyFormat,
}
impl DatePreference {
/// Returns true if day comes before month in ambiguous dates.
pub fn is_dmy(&self) -> bool {
matches!(self, DatePreference::DmyFormat)
}
}