use crate::dtype::{FloatKind, IntKind};
use crate::formats::Format;
use crate::options::CastPolicy;
#[derive(Clone, Debug)]
pub struct ReadOptions {
pub lazy: bool,
pub chunk_elements: usize,
pub int_as: Option<IntKind>,
pub float_as: Option<FloatKind>,
pub cast_policy: CastPolicy,
pub format: Option<Format>,
pub allow_unknown_globals: bool,
pub max_alloc: usize,
pub keep_record_arrays: bool,
}
impl Default for ReadOptions {
fn default() -> Self {
ReadOptions {
lazy: false,
chunk_elements: 1 << 20,
int_as: None,
float_as: None,
cast_policy: CastPolicy::Strict,
format: None,
allow_unknown_globals: false,
max_alloc: 8 << 30,
keep_record_arrays: false,
}
}
}
impl ReadOptions {
pub fn new() -> Self {
Self::default()
}
pub fn lazy(mut self, yes: bool) -> Self {
self.lazy = yes;
self
}
pub fn chunk_elements(mut self, n: usize) -> Self {
self.chunk_elements = n.max(1);
self
}
pub fn int_as(mut self, kind: IntKind) -> Self {
self.int_as = Some(kind);
self
}
pub fn float_as(mut self, kind: FloatKind) -> Self {
self.float_as = Some(kind);
self
}
pub fn cast_policy(mut self, p: CastPolicy) -> Self {
self.cast_policy = p;
self
}
pub fn format(mut self, fmt: Format) -> Self {
self.format = Some(fmt);
self
}
pub fn max_alloc(mut self, bytes: usize) -> Self {
self.max_alloc = bytes;
self
}
}
impl ReadOptions {
pub fn allow_unknown_globals(mut self, yes: bool) -> Self {
self.allow_unknown_globals = yes;
self
}
}