};
use crate::{
- dictionary::{self, Dictionary},
+ dictionary::{self, Dictionary, VarWidth},
encoding::{default_encoding, get_encoding, Error as EncodingError},
endian::Endian,
format::{Error as FormatError, Spec, UncheckedSpec},
identifier::{Error as IdError, Identifier},
raw::{
self, LongStringMissingValueRecord, MissingValues, ProductInfoRecord, RawDocumentLine,
- RawStr, RawString, VarDisplayRecord, VarType,
+ RawStr, RawString, VarDisplayRecord, VarType, DecodedRecord,
},
};
use chrono::{NaiveDate, NaiveDateTime, NaiveTime};
pub fn decode(
- headers: Vec<raw::Record>,
- encoding: &'static Encoding,
- warn: &impl Fn(Error),
+ headers: Vec<DecodedRecord>,
+ decoder: raw::Decoder,
) -> Result<(Vec<Record>, Metadata), Error> {
+ let dictionary = Dictionary::new(decoder.encoding);
let mut decoder = Decoder {
- raw: raw::Decoder {
- encoding,
- warn: Box::new(|error| println!("{error}")),
- },
- encoding,
+ raw: decoder,
variables: HashMap::new(),
var_names: HashMap::new(),
- dictionary: Dictionary::new(encoding),
+ dictionary,
n_dict_indexes: 0,
n_generated_names: 0,
};
- let h = Headers::new(&headers, &decoder, warn);
+ let h = Headers::new(&headers, &decoder);
let Some(header) = h.header else {
return Err(Error::MissingHeaderRecord);
};