pub struct Cgats { /* private fields */ }
Expand description

The CGATS data

Implementations

Calculate the DeltaE between each value of two CGATS data sets. Returns an error if either of the two sets do not contain Lab data.

Calculate DeltaE and generate a report

Determine if it is possible to calculate DeltaE between two CGATS data sets.

Creates a new empty Cgats object

Creates a new empty Cgats object with the specified capacity

Returns a summary string:

Vendor[ColorTypes; n]

use cgats::Cgats;

let cgats: Cgats =
"CGATS.17
BEGIN_DATA_FORMAT
SAMPLE_ID	RGB_R	RGB_G	RGB_B
END_DATA_FORMAT
BEGIN_DATA
1	0	0	0
2	128	128	128
3	255	255	255
END_DATA"
.parse().unwrap();

assert_eq!(cgats.summary(), "Cgats[Rgb; 3]");

Returns a reference the Vendor

Find the MetaData value by key

use cgats::Cgats;

let cgats: Cgats =
"CGATS.17
NUMBER_OF_FIELDS 4
BEGIN_DATA_FORMAT
SAMPLE_ID	RGB_R	RGB_G	RGB_B
END_DATA_FORMAT
NUMBER_OF_SETS 3
BEGIN_DATA
1	0	0	0
2	128	128	128
3	255	255	255
END_DATA"
.parse().unwrap();

assert_eq!(cgats.get_metadata("NUMBER_OF_FIELDS"), Some("4"));
assert_eq!(cgats.get_metadata("NUMBER_OF_SETS"), Some("3"));

Returns a mutable reference to a metadata value by key

Insert a MetaData Key:Value, overwriting if it exists

Iterator over the DataPoints in a Cgats object

Iterator over the DataPoints with their corresponding Field keys

use cgats::{Cgats, Field::*, DataPoint::*};

let cgats: Cgats =
"CGATS.17
BEGIN_DATA_FORMAT
SAMPLE_ID	DE2000
END_DATA_FORMAT
BEGIN_DATA
1	1.23
2	3.21
END_DATA"
.parse().unwrap();

let mut iter = cgats.iter_with_fields();

assert_eq!(iter.next(), Some((&SAMPLE_ID, &Int(1))));
assert_eq!(iter.next(), Some((&DE_2000, &Float(1.23))));
assert_eq!(iter.next(), Some((&SAMPLE_ID, &Int(2))));
assert_eq!(iter.next(), Some((&DE_2000, &Float(3.21))));
assert_eq!(iter.next(), None);

Mutable iterator over the DataPoints with their corresponding Field keys. Field values are cloned.

use cgats::{Cgats, Field::*, DataPoint::*};

let mut cgats: Cgats =
"CGATS.17
BEGIN_DATA_FORMAT
SAMPLE_ID	DE2000
END_DATA_FORMAT
BEGIN_DATA
1	1.23
2	3.21
END_DATA"
.parse().unwrap();

{
    let mut iter = cgats.iter_mut_with_fields();
    
    assert_eq!(iter.next(), Some((SAMPLE_ID, &mut Int(1))));
    assert_eq!(iter.next(), Some((DE_2000, &mut Float(1.23))));
    assert_eq!(iter.next(), Some((SAMPLE_ID, &mut Int(2))));
    
    if let Some((_field, data_point)) = iter.next() {
        *data_point = Float(4.56);
    }
    
    assert_eq!(iter.next(), None);
}

assert_eq!(cgats[3], Float(4.56));

Iterator over the fields of the DataFormat

Mutable iterator over the fields of the DataFormat

Mutable iterator over the DataPoints in a Cgats object

Read a file into a Cgats object

Write a Cgats object to a file

Write a Cgats object to a Write object

Returns the total number of data points in the set (rows x cols)

Returns true if self.len() == 0

Returns the total number of rows (samples) in the set

Returns the total number of columns (fields) in the set

Iterator over the data points in a given sample row

Returns the first row containing the given values

Returns a row index to the first row containing the given values

Remove a row from a sample set by row index and return the row. Returns none if the row index is greater than or equal to the number of rows.

use cgats::Cgats;

let mut cgats: Cgats =
"CGATS.17
BEGIN_DATA_FORMAT
SAMPLE_ID	DE2000
END_DATA_FORMAT
BEGIN_DATA
1	1.23
2	3.21
3	4.56
END_DATA"
.parse().unwrap();

{
    let mut row = cgats.remove_row(1).unwrap();
    assert_eq!(row.next().unwrap(), 2);
    assert_eq!(row.next().unwrap(), 3.21);
    assert_eq!(row.next(), None);
}

{
    let mut row = cgats.remove_row(1).unwrap();
    assert_eq!(row.next().unwrap(), 3);
    assert_eq!(row.next().unwrap(), 4.56);
    assert_eq!(row.next(), None);
}

{
    assert!(cgats.remove_row(1).is_none());
}

Move a row from one row index to another. Returns an error if the indices are out of range

use cgats::Cgats;

let mut cgats: Cgats =
"CGATS.17
BEGIN_DATA_FORMAT
SAMPLE_ID	DE2000
END_DATA_FORMAT
BEGIN_DATA
1	1.23
2	3.21
3	4.56
END_DATA"
.parse().unwrap();

cgats.move_row(2, 1).unwrap();

{
    let mut last_row = cgats.get_row(2).unwrap();
    assert_eq!(last_row.next().unwrap(), &2);
    assert_eq!(last_row.next().unwrap(), &3.21);
    assert_eq!(last_row.next(), None);
}

cgats.move_row(0, 2).unwrap();

{
    let mut last_row = cgats.get_row(2).unwrap();
    assert_eq!(last_row.next().unwrap(), &1);
    assert_eq!(last_row.next().unwrap(), &1.23);
    assert_eq!(last_row.next(), None);
}

Re-order rows to transpose for chart layouts with a given current chart width (LGOROWLENGTH)

Iterator of mutable references to data points in a given sample row

Iterator over the rows of DataPoints

Returns an iterator over the data points in a given column (field)

Find a column by it’s Field. Returns None if the Field does not exist.

Iterator of mutable references to data points in a given column (field)

Find a mutable column by it’s Field. Returns None if the Field does not exist.

Iterator over the columns of DataPoints

Iterator over columns of DataPoints with their corresponding Fields

Returns a list of ColorTypes based on the contents of the DATA_FORMAT

Determines if the data contains a ColorType

Re-number the SAMPLE_ID field starting from 0

Re-number the SAMPLE_ID field starting from a given integer

Returns the position of a column with a given Field

Returns None if the DataFormat does not contain the Field

Insert a column of DataPoints

Append a column of DataPoints

Insert a row of DataPoints at a row index

Append a row of DataPoints

Append the rows from another Cgats. Returns an error if the DataFormats do not match.

Concatenate the rows from multiple Cgats

Convert the CGATS to a ColorBurst linearization format.

Convert ColorBurst linearization format to a conventional CGATS format

Trait Implementations

Format data to a fmt::Formatter
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Formats the value using the given formatter. Read more
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more

Index into Cgats by (column, row)

use cgats::Cgats;

let mut cgats: Cgats =
"CGATS.17
BEGIN_DATA_FORMAT
RGB_R	RGB_G	RGB_B
END_DATA_FORMAT
BEGIN_DATA
0	1	2
126	127	128
253	254	255
END_DATA"
.parse().unwrap();

assert_eq!(cgats[(0, 0)], 0);
assert_eq!(cgats[(2, 1)], 128);
assert_eq!(cgats[(2, 2)], 255);
The returned type after indexing.

Index into Cgats by usize

use cgats::Cgats;

let mut cgats: Cgats =
"CGATS.17
BEGIN_DATA_FORMAT
RGB_R	RGB_G	RGB_B
END_DATA_FORMAT
BEGIN_DATA
0	1	2
126	127	128
253	254	255
END_DATA"
.parse().unwrap();

assert_eq!(cgats[0], 0);
assert_eq!(cgats[5], 128);
assert_eq!(cgats[8], 255);
The returned type after indexing.
Performs the mutable indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more
The output of a successfull add
Try to add the two values
The output of a successful division
Divides the values. Returns None if either value is not a type that can divide.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.