Module raccoon::entry [−][src]
A cell-like entity that can store the most common primitives.
DataEntry
is usually used in conjonction with Series
. By itself the entry has not much use. The DataType
enumeration provides the type of a DataEntry
.
Note on Memory Efficiency
Due to the way Rust allocates memory for enum
s, the size of a single DataEntry
will be equal to the largest data
contained in the enum
, which in this case is the String
pointer (3 times the size of usize
). Hence using
DataEntry::Integer(-32)
or DataEntry::Long(-32)
will make no difference in the memory used by Rust. The same
counts for DataEntry::Float
and DataEntry::Double
.
The smaller types are only included for completeness sake and size they are the default integer and floating point
sizes used by Rust. However, using 32 bit numericals will not reduce the memory footprint if a DataEntry
. This is
also why numerical types smaller than 32 bits are not supported. It is therefore encouraged to use 64 bit numerals
as they provide more precision or larger max/min values.
Examples
Creating a DataEntry
like any other Rust enum
:
use raccoon::DataEntry; let _entry = DataEntry::ULong(123_456_789_987u64);
Converting a DataEntry
into another DataType
:
use raccoon::{DataType, DataEntry}; let entry = DataEntry::from(true); assert_eq!(entry.data_type(), DataType::Boolean); let new_entry = entry.convert_to(&DataType::Text); assert_eq!(new_entry, DataEntry::Text("true".to_owned()));
Recovering the data type of a series:
use raccoon::{Series, DataType}; let series = Series::from(vec!['a', 'b', 'c']); let data_type = series.data_type(); assert_eq!(data_type, &DataType::Character);
Enums
DataEntry |
A cell-like data entry. Note that |
DataType |
The data type any entry can take. |