#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct CsvLimits {
max_input_bytes: usize,
max_records: usize,
max_fields_per_record: usize,
max_field_bytes: usize,
}
impl CsvLimits {
pub const fn conservative() -> Self {
Self {
max_input_bytes: 1 << 20,
max_records: 1 << 16,
max_fields_per_record: 1 << 10,
max_field_bytes: 1 << 16,
}
}
pub const fn permissive() -> Self {
Self {
max_input_bytes: 1 << 28,
max_records: 1 << 24,
max_fields_per_record: 1 << 16,
max_field_bytes: 1 << 24,
}
}
pub const fn max_input_bytes(&self) -> usize {
self.max_input_bytes
}
pub const fn max_records(&self) -> usize {
self.max_records
}
pub const fn max_fields_per_record(&self) -> usize {
self.max_fields_per_record
}
pub const fn max_field_bytes(&self) -> usize {
self.max_field_bytes
}
pub const fn with_max_input_bytes(mut self, value: usize) -> Self {
self.max_input_bytes = value;
self
}
pub const fn with_max_records(mut self, value: usize) -> Self {
self.max_records = value;
self
}
pub const fn with_max_fields_per_record(mut self, value: usize) -> Self {
self.max_fields_per_record = value;
self
}
pub const fn with_max_field_bytes(mut self, value: usize) -> Self {
self.max_field_bytes = value;
self
}
}
impl Default for CsvLimits {
fn default() -> Self {
Self::conservative()
}
}