Crate citi

Source
Expand description

Input/Output for CITI records

The standard, defines the following entities:

NameDescription
RecordThe entire contents of the record
HeaderHeader of the record
DataOne or more data arrays
KeywordDefine 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 to VAR_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
DataArray
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
ParseError
Error from parsing a line
ReadError
Error during reading
WriteError
Error during writing

Type Aliases§

Result
Crate interface result