X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=rust%2Fsrc%2Flib.rs;h=c793f44cbbaa12f7c329599d7dc6f8dc9d735d3f;hb=3aadbf4b5339a293cafa3b0e5f0529d8818ad81d;hp=6dc13b586a96e7949d0e21e5d06d9884ca26c0ad;hpb=2f5387c960ae55adfd09d698566430947c28615e;p=pspp diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 6dc13b586a..c793f44cbb 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1,87 +1,19 @@ -use std::io::Error as IoError; -use thiserror::Error as ThisError; - pub mod endian; pub mod raw; +pub mod cooked; pub mod sack; +pub mod encoding; +pub mod format; +pub mod identifier; + +#[derive(Copy, Clone, Debug)] +pub enum Compression { + Simple, + ZLib, +} -#[derive(ThisError, Debug)] -pub enum Error { - #[error("Not an SPSS system file")] - NotASystemFile, - - #[error("Invalid magic number {0:?}")] - BadMagic([u8; 4]), - - #[error("I/O error ({0})")] - Io(#[from] IoError), - - #[error("Invalid SAV compression code {0}")] - InvalidSavCompression(u32), - - #[error("Invalid ZSAV compression code {0}")] - InvalidZsavCompression(u32), - - #[error("Variable record at offset {offset:#x} specifies width {width} not in valid range [-1,255).")] - BadVariableWidth { offset: u64, width: i32 }, - - #[error("Document record at offset {offset:#x} has document line count ({n}) greater than the maximum number {max}.")] - BadDocumentLength { offset: u64, n: u32, max: u32 }, - - #[error("At offset {offset:#x}, Unrecognized record type {rec_type}.")] - BadRecordType { offset: u64, rec_type: u32 }, - - #[error("At offset {offset:#x}, variable label code ({code}) is not 0 or 1.")] - BadVariableLabelCode { offset: u64, code: u32 }, - - #[error( - "At offset {offset:#x}, numeric missing value code ({code}) is not -3, -2, 0, 1, 2, or 3." - )] - BadNumericMissingValueCode { offset: u64, code: i32 }, - - #[error("At offset {offset:#x}, string missing value code ({code}) is not 0, 1, 2, or 3.")] - BadStringMissingValueCode { offset: u64, code: i32 }, - - #[error("At offset {offset:#x}, number of value labels ({n}) is greater than the maximum number {max}.")] - BadNumberOfValueLabels { offset: u64, n: u32, max: u32 }, - - #[error("At offset {offset:#x}, number of variables indexes ({n}) is greater than the maximum number ({max}).")] - BadNumberOfVarIndexes { offset: u64, n: u32, max: u32 }, - - #[error("At offset {offset:#x}, record type 7 subtype {subtype} is too large with element size {size} and {count} elements.")] - ExtensionRecordTooLarge { - offset: u64, - subtype: u32, - size: u32, - count: u32, - }, - - #[error("Unexpected end of file at offset {offset:#x}, {case_ofs} bytes into a {case_len}-byte case.")] - EofInCase { - offset: u64, - case_ofs: u64, - case_len: usize, - }, - - #[error( - "Unexpected end of file at offset {offset:#x}, {case_ofs} bytes into a compressed case." - )] - EofInCompressedCase { offset: u64, case_ofs: u64 }, - - #[error("Data ends at offset {offset:#x}, {case_ofs} bytes into a compressed case.")] - PartialCompressedCase { offset: u64, case_ofs: u64 }, - - #[error("At {case_ofs} bytes into compressed case starting at offset {offset:#x}, a string was found where a number was expected.")] - CompressedNumberExpected { offset: u64, case_ofs: u64 }, - - #[error("At {case_ofs} bytes into compressed case starting at offset {offset:#x}, a number was found where a string was expected.")] - CompressedStringExpected { offset: u64, case_ofs: u64 }, - - #[error("Block count {n_blocks} in ZLIB trailer at offset {offset:#x} differs from expected block count {expected_n_blocks} calculated from trailer length {ztrailer_len}.")] - BadZlibTrailerNBlocks { - offset: u64, - n_blocks: u32, - expected_n_blocks: u64, - ztrailer_len: u64, - }, +#[derive(Clone, Debug)] +pub enum CategoryLabels { + VarLabels, + CountedValues, }