Expand description
Input/Output for CITI records
The standard, defines the following entities:
Name | Description |
---|---|
Record | The entire contents of the record |
Header | Header of the record |
Data | One or more data arrays |
Keyword | Define the header contents |
As this is a custom ASCII record type, the standard is not as simple as one would like. The standard is followed as closely as is reasonable. The largest changes are in the extension of the keywords.
§Non-Standard Type
A non-standard but industry prevelent comment section is added formated with a bang:
!COMMENT
These are used to provide internal comments.
§IO Example
The object must implement the BufRead
trait since CITI files are read line-by-line.
As a result, two reads will lead to a fail on the second read, since the buffer is empty.
Read file:
use citi::Record;
use std::fs::File;
let mut file = File::open("file.cti").unwrap();
let record = Record::from_reader(&mut file);
Write file:
use citi::Record;
use std::fs::File;
let record = Record::default();
let mut file = File::create("file.cti").unwrap();
record.to_writer(&mut file);
§Input-Output Consistency:
General input-output consistency cannot be guaranteed with CITI records because of their design. That is, if a record is read in and read out, the byte representation of the record may change, exact floating point representations may change, but the record will contain the same information. The following is not guaranteed:
- ASCII representation of floating points may change because of the String -> Float -> String conversion.
- Floats may be shifted in exponential format.
- All
SEG_LIST
keywords will be converted toVAR_LIST
Macros§
- assert_
array_ relative_ eq - Relative assert on two arrays
- assert_
complex_ array_ relative_ eq - Relative assert on two arrays of complex numbers
- assert_
files_ equal - Assert two files on disk are equal
Structs§
- Constant
- Define a constant in the file
- Data
Array - A named, formatted, data array
- Device
- Device-specific value.
- Header
- The file header
- Record
- Representation of a file
- Var
- The independent variable
Enums§
- Error
- Crate error
- Keyword
- Representation of the per-line keywords
- Parse
Error - Error from parsing a line
- Read
Error - Error during reading
- Write
Error - Error during writing
Type Aliases§
- Result
- Crate interface result