Drop use of Cow
[pspp] / rust / src / cooked.rs
index 1cb878f120d6768cff919e86c60c368a9c8347a5..78eaf138c2951fc831d72d5da98cbd8005542c73 100644 (file)
@@ -4,14 +4,14 @@ use std::{
 };
 
 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};
@@ -285,24 +285,20 @@ impl<'a> Headers<'a> {
 
 
 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);
     };