projects
/
pspp
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
19eebc6
)
Make decoding consume the record
author
Ben Pfaff
<blp@cs.stanford.edu>
Wed, 31 Jan 2024 06:21:18 +0000
(22:21 -0800)
committer
Ben Pfaff
<blp@cs.stanford.edu>
Wed, 31 Jan 2024 06:21:18 +0000
(22:21 -0800)
rust/src/raw.rs
patch
|
blob
|
history
diff --git
a/rust/src/raw.rs
b/rust/src/raw.rs
index 0250520afc3b3ffdfee4fc5da9951d3f538952bb..bbe2b46d36754ff3f7aee5fcd83ef8b7c91a675a 100644
(file)
--- a/
rust/src/raw.rs
+++ b/
rust/src/raw.rs
@@
-287,7
+287,7
@@
impl Record {
}
}
}
}
- pub fn decode(
&
self, decoder: &Decoder) -> Result<DecodedRecord, Error> {
+ pub fn decode(self, decoder: &Decoder) -> Result<DecodedRecord, Error> {
Ok(match self {
Record::Header(record) => record.decode(decoder),
Record::Variable(record) => record.decode(decoder),
Ok(match self {
Record::Header(record) => record.decode(decoder),
Record::Variable(record) => record.decode(decoder),
@@
-307,7
+307,7
@@
impl Record {
Record::NumberOfCases(record) => DecodedRecord::NumberOfCases(record.clone()),
Record::Text(record) => record.decode(decoder),
Record::OtherExtension(record) => DecodedRecord::OtherExtension(record.clone()),
Record::NumberOfCases(record) => DecodedRecord::NumberOfCases(record.clone()),
Record::Text(record) => record.decode(decoder),
Record::OtherExtension(record) => DecodedRecord::OtherExtension(record.clone()),
- Record::EndOfHeaders(record) => DecodedRecord::EndOfHeaders(
*
record),
+ Record::EndOfHeaders(record) => DecodedRecord::EndOfHeaders(record),
Record::ZHeader(record) => DecodedRecord::ZHeader(record.clone()),
Record::ZTrailer(record) => DecodedRecord::ZTrailer(record.clone()),
Record::Cases(record) => DecodedRecord::Cases(record.clone()),
Record::ZHeader(record) => DecodedRecord::ZHeader(record.clone()),
Record::ZTrailer(record) => DecodedRecord::ZTrailer(record.clone()),
Record::Cases(record) => DecodedRecord::Cases(record.clone()),
@@
-495,7
+495,7
@@
impl HeaderRecord<RawString> {
})
}
})
}
- pub fn decode(
&
self, decoder: &Decoder) -> DecodedRecord {
+ pub fn decode(self, decoder: &Decoder) -> DecodedRecord {
let eye_catcher = decoder.decode(&self.eye_catcher).to_string();
let file_label = decoder.decode(&self.file_label).to_string();
let creation_date = decoder.decode(&self.creation_date).to_string();
let eye_catcher = decoder.decode(&self.eye_catcher).to_string();
let file_label = decoder.decode(&self.file_label).to_string();
let creation_date = decoder.decode(&self.creation_date).to_string();
@@
-823,9
+823,9
@@
impl RawValue {
Ok(Some(values))
}
Ok(Some(values))
}
- fn decode(
&
self, decoder: &Decoder) -> Value<String> {
+ fn decode(self, decoder: &Decoder) -> Value<String> {
match self {
match self {
- Self::Number(x) => Value::Number(
*
x),
+ Self::Number(x) => Value::Number(x),
Self::String(s) => Value::String(decoder.decode_exact_length(&s.0).into()),
}
}
Self::String(s) => Value::String(decoder.decode_exact_length(&s.0).into()),
}
}
@@
-1342,7
+1342,7
@@
impl VariableRecord<RawString, RawStr<8>> {
}))
}
}))
}
- pub fn decode(
&
self, decoder: &Decoder) -> DecodedRecord {
+ pub fn decode(self, decoder: &Decoder) -> DecodedRecord {
DecodedRecord::Variable(VariableRecord {
offsets: self.offsets.clone(),
width: self.width,
DecodedRecord::Variable(VariableRecord {
offsets: self.offsets.clone(),
width: self.width,
@@
-1596,7
+1596,7
@@
impl ValueLabelRecord<RawStr<8>, RawString> {
})))
}
})))
}
- fn decode(
&
self, decoder: &Decoder) -> ValueLabelRecord<RawStr<8>, String> {
+ fn decode(self, decoder: &Decoder) -> ValueLabelRecord<RawStr<8>, String> {
let labels = self
.labels
.iter()
let labels = self
.labels
.iter()
@@
-1659,7
+1659,7
@@
impl DocumentRecord<RawDocumentLine> {
}
}
}
}
- pub fn decode(
&
self, decoder: &Decoder) -> DecodedRecord {
+ pub fn decode(self, decoder: &Decoder) -> DecodedRecord {
DecodedRecord::Document(DocumentRecord {
offsets: self.offsets.clone(),
lines: self
DecodedRecord::Document(DocumentRecord {
offsets: self.offsets.clone(),
lines: self
@@
-1906,7
+1906,7
@@
impl ExtensionRecord for MultipleResponseRecord<RawString, RawString> {
}
impl MultipleResponseRecord<RawString, RawString> {
}
impl MultipleResponseRecord<RawString, RawString> {
- fn decode(
&
self, decoder: &Decoder) -> DecodedRecord {
+ fn decode(self, decoder: &Decoder) -> DecodedRecord {
let mut sets = Vec::new();
for set in self.0.iter() {
if let Some(set) = set.decode(decoder).issue_warning(&decoder.warn) {
let mut sets = Vec::new();
for set in self.0.iter() {
if let Some(set) = set.decode(decoder).issue_warning(&decoder.warn) {
@@
-2129,7
+2129,7
@@
impl ExtensionRecord for LongStringMissingValueRecord<RawString, RawStr<8>> {
}
impl LongStringMissingValueRecord<RawString, RawStr<8>> {
}
impl LongStringMissingValueRecord<RawString, RawStr<8>> {
- pub fn decode(
&
self, decoder: &Decoder) -> LongStringMissingValueRecord<Identifier, String> {
+ pub fn decode(self, decoder: &Decoder) -> LongStringMissingValueRecord<Identifier, String> {
let mut mvs = Vec::with_capacity(self.0.len());
for mv in self.0.iter() {
if let Some(mv) = mv
let mut mvs = Vec::with_capacity(self.0.len());
for mv in self.0.iter() {
if let Some(mv) = mv
@@
-2219,25
+2219,25
@@
impl TextRecord {
text: extension.data.into(),
}
}
text: extension.data.into(),
}
}
- pub fn decode(
&
self, decoder: &Decoder) -> DecodedRecord {
+ pub fn decode(self, decoder: &Decoder) -> DecodedRecord {
match self.rec_type {
TextRecordType::VariableSets => {
match self.rec_type {
TextRecordType::VariableSets => {
- DecodedRecord::VariableSets(VariableSetRecord::decode(self, decoder))
+ DecodedRecord::VariableSets(VariableSetRecord::decode(
&
self, decoder))
}
TextRecordType::ProductInfo => {
}
TextRecordType::ProductInfo => {
- DecodedRecord::ProductInfo(ProductInfoRecord::decode(self, decoder))
+ DecodedRecord::ProductInfo(ProductInfoRecord::decode(
&
self, decoder))
}
TextRecordType::LongNames => {
}
TextRecordType::LongNames => {
- DecodedRecord::LongNames(LongNamesRecord::decode(self, decoder))
+ DecodedRecord::LongNames(LongNamesRecord::decode(
&
self, decoder))
}
TextRecordType::VeryLongStrings => {
}
TextRecordType::VeryLongStrings => {
- DecodedRecord::VeryLongStrings(VeryLongStringsRecord::decode(self, decoder))
+ DecodedRecord::VeryLongStrings(VeryLongStringsRecord::decode(
&
self, decoder))
}
TextRecordType::FileAttributes => {
}
TextRecordType::FileAttributes => {
- DecodedRecord::FileAttributes(FileAttributeRecord::decode(self, decoder))
+ DecodedRecord::FileAttributes(FileAttributeRecord::decode(
&
self, decoder))
}
TextRecordType::VariableAttributes => {
}
TextRecordType::VariableAttributes => {
- DecodedRecord::VariableAttributes(VariableAttributeRecord::decode(self, decoder))
+ DecodedRecord::VariableAttributes(VariableAttributeRecord::decode(
&
self, decoder))
}
}
}
}
}
}
@@
-2863,7
+2863,7
@@
impl ExtensionRecord for LongStringValueLabelRecord<RawString, RawString> {
}
impl LongStringValueLabelRecord<RawString, RawString> {
}
impl LongStringValueLabelRecord<RawString, RawString> {
- fn decode(
&
self, decoder: &Decoder) -> LongStringValueLabelRecord<Identifier, String> {
+ fn decode(self, decoder: &Decoder) -> LongStringValueLabelRecord<Identifier, String> {
let mut labels = Vec::with_capacity(self.0.len());
for label in &self.0 {
match label.decode(decoder) {
let mut labels = Vec::with_capacity(self.0.len());
for label in &self.0 {
match label.decode(decoder) {