LongNamesRecord, LongStringMissingValueRecord, LongStringValueLabelRecord,
MissingValues, MissingValuesError, MultipleResponseRecord, NumberOfCasesRecord,
ProductInfoRecord, RawStrArray, RawString, RawWidth, ValueLabel, ValueLabelRecord,
- VarDisplayRecord, VariableAttributeRecord, VariableRecord, VariableSetRecord,
+ VarDisplayRecord, VariableAttributesRecord, VariableRecord, VariableSetRecord,
VeryLongStringsRecord, ZHeader, ZTrailer,
},
},
pub long_names: Vec<LongNamesRecord>,
pub very_long_strings: Vec<VeryLongStringsRecord>,
pub file_attributes: Vec<FileAttributesRecord>,
- pub variable_attributes: Vec<VariableAttributeRecord>,
+ pub variable_attributes: Vec<VariableAttributesRecord>,
pub other_extension: Vec<Extension>,
pub end_of_headers: Option<u32>,
pub z_header: Option<ZHeader>,
LongNames(RawLongNamesRecord),
VeryLongStrings(RawVeryLongStringsRecord),
FileAttributes(RawFileAttributesRecord),
- Text(TextRecord),
+ VariableAttributes(RawVariableAttributesRecord),
OtherExtension(Extension),
EndOfHeaders(u32),
ZHeader(ZHeader),
LongNames(LongNamesRecord),
VeryLongStrings(VeryLongStringsRecord),
FileAttributes(FileAttributesRecord),
- VariableAttributes(VariableAttributeRecord),
+ VariableAttributes(VariableAttributesRecord),
OtherExtension(Extension),
EndOfHeaders(u32),
ZHeader(ZHeader),
DecodedRecord::VeryLongStrings(record.decode(decoder))
}
Record::FileAttributes(record) => DecodedRecord::FileAttributes(record.decode(decoder)),
- Record::Text(record) => record.decode(decoder),
+ Record::VariableAttributes(record) => {
+ DecodedRecord::VariableAttributes(record.decode(decoder))
+ }
Record::OtherExtension(record) => DecodedRecord::OtherExtension(record.clone()),
Record::EndOfHeaders(record) => DecodedRecord::EndOfHeaders(record),
Record::ZHeader(record) => DecodedRecord::ZHeader(record.clone()),
pub struct TextRecord {
pub offsets: Range<u64>,
- /// Type of record.
- pub rec_type: TextRecordType,
-
/// The text content of the record.
pub text: RawString,
}
-#[derive(Clone, Copy, Debug)]
-pub enum TextRecordType {
- VariableAttributes,
-}
-
impl TextRecord {
fn parse(extension: Extension, name: &str) -> Result<TextRecord, Warning> {
extension.check_size(&ExtensionRecord {
count: None,
name,
})?;
- Ok(Self::new(extension, TextRecordType::VariableAttributes))
- }
- fn new(extension: Extension, rec_type: TextRecordType) -> Self {
- Self {
+ Ok(Self {
offsets: extension.offsets,
- rec_type,
text: extension.data.into(),
- }
- }
- pub fn decode(self, decoder: &mut Decoder) -> DecodedRecord {
- match self.rec_type {
- TextRecordType::VariableAttributes => {
- DecodedRecord::VariableAttributes(VariableAttributeRecord::decode(&self, decoder))
- }
- }
+ })
}
}
}
#[derive(Clone, Debug)]
-pub struct VariableAttributeRecord(pub Vec<VarAttributes>);
+pub struct RawVariableAttributesRecord(TextRecord);
+
+#[derive(Clone, Debug)]
+pub struct VariableAttributesRecord(pub Vec<VarAttributes>);
-impl VariableAttributeRecord {
- fn decode(source: &TextRecord, decoder: &mut Decoder) -> Self {
- let decoded = decoder.decode(&source.text);
+impl RawVariableAttributesRecord {
+ fn parse(extension: Extension) -> Result<Record, Warning> {
+ Ok(Record::VariableAttributes(Self(TextRecord::parse(
+ extension,
+ "variable attributes record",
+ )?)))
+ }
+ fn decode(self, decoder: &mut Decoder) -> VariableAttributesRecord {
+ let decoded = decoder.decode(&self.0.text);
let mut input = decoded.as_ref();
let mut var_attribute_sets = Vec::new();
while !input.is_empty() {
var_attribute_sets.push(var_attribute);
input = rest;
}
- VariableAttributeRecord(var_attribute_sets)
+ VariableAttributesRecord(var_attribute_sets)
}
}
13 => RawLongNamesRecord::parse(extension),
14 => RawVeryLongStringsRecord::parse(extension),
17 => RawFileAttributesRecord::parse(extension),
- 18 => Ok(Record::Text(TextRecord::new(
- extension,
- TextRecordType::VariableAttributes,
- ))),
+ 18 => RawVariableAttributesRecord::parse(extension),
_ => Ok(Record::OtherExtension(extension)),
};
match result {