X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=rust%2Fsrc%2Flib.rs;h=3eb4bbae4eba2032a46a954c05c98d0d99959525;hb=6165ed413d9aa818e3246d0a063c646dc4efc7e5;hp=482bd081979a8ec060945304729680ad8c081323;hpb=163d8e396c5b2fd5afd68903d08bff938f13d048;p=pspp diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 482bd08197..3eb4bbae4e 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1,126 +1,8 @@ -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 endian; pub mod format; - -#[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, - }, - - #[error("At offset {offset:#x}, {record} has bad size {size} bytes instead of the expected {expected_size}.")] - BadRecordSize { offset: u64, record: String, size: u32, expected_size: u32 }, - - #[error("At offset {offset:#x}, {record} has bad count {count} instead of the expected {expected_count}.")] - BadRecordCount { offset: u64, record: String, count: u32, expected_count: u32 }, - - #[error("The encoding record at offset {offset:#x} contains an encoding name that is not valid UTF-8.")] - BadEncodingName { offset: u64 }, - - #[error("In long string missing values record starting at offset {record_offset:#x}, value length at offset {offset:#x} is {value_len} instead of the expected 8.")] - BadLongMissingValueLength { record_offset: u64, offset: u64, value_len: u32 }, - - #[error("This file has corrupted metadata written by a buggy version of PSPP. To ensure that other software can read it correctly, save a new copy of the file.")] - BadLongMissingValueFormat, - - #[error("File creation date {creation_date} is not in the expected format \"DD MMM YY\" format. Using 01 Jan 1970.")] - InvalidCreationDate { creation_date: String }, - - #[error("File creation time {creation_time} is not in the expected format \"HH:MM:SS\" format. Using midnight.")] - InvalidCreationTime { creation_time: String }, - - #[error("Details TBD")] - TBD, -} - -#[derive(Copy, Clone, Debug)] -pub enum Compression { - Simple, - ZLib, -} - -#[derive(Clone, Debug)] -pub enum CategoryLabels { - VarLabels, - CountedValues, -} +pub mod identifier; +pub mod raw; +pub mod sack; +pub mod locale_charset;