Enum calamine::DataType

source ·
pub enum DataType {
    Int(i64),
    Float(f64),
    String(String),
    Bool(bool),
    DateTime(f64),
    DateTimeIso(String),
    DurationIso(String),
    Error(CellErrorType),
    Empty,
}
Expand description

An enum to represent all different data types that can appear as a value in a worksheet cell

Variants§

§

Int(i64)

Signed integer

§

Float(f64)

Float

§

String(String)

String

§

Bool(bool)

Boolean

§

DateTime(f64)

Date or Time

§

DateTimeIso(String)

Date, Time or DateTime in ISO 8601

§

DurationIso(String)

Duration in ISO 8601

§

Error(CellErrorType)

Error

§

Empty

Empty cell

Implementations§

source§

impl DataType

source

pub fn is_empty(&self) -> bool

Assess if datatype is empty

source

pub fn is_int(&self) -> bool

Assess if datatype is a int

source

pub fn is_float(&self) -> bool

Assess if datatype is a float

source

pub fn is_bool(&self) -> bool

Assess if datatype is a bool

source

pub fn is_string(&self) -> bool

Assess if datatype is a string

source

pub fn get_int(&self) -> Option<i64>

Try getting int value

source

pub fn get_float(&self) -> Option<f64>

Try getting float value

source

pub fn get_bool(&self) -> Option<bool>

Try getting bool value

source

pub fn get_string(&self) -> Option<&str>

Try getting string value

source

pub fn as_string(&self) -> Option<String>

Try converting data type into a string

source

pub fn as_i64(&self) -> Option<i64>

Try converting data type into an int

source

pub fn as_f64(&self) -> Option<f64>

Try converting data type into a float

Trait Implementations§

source§

impl Clone for DataType

source§

fn clone(&self) -> DataType

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for DataType

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for DataType

source§

fn default() -> DataType

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for DataType

source§

fn deserialize<D>(deserializer: D) -> Result<DataType, D::Error>where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for DataType

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a str> for DataType

source§

fn from(v: &'a str) -> Self

Converts to this type from the input type.
source§

impl From<()> for DataType

source§

fn from(_: ()) -> Self

Converts to this type from the input type.
source§

impl From<CellErrorType> for DataType

source§

fn from(v: CellErrorType) -> Self

Converts to this type from the input type.
source§

impl<T> From<Option<T>> for DataTypewhere DataType: From<T>,

source§

fn from(v: Option<T>) -> Self

Converts to this type from the input type.
source§

impl From<String> for DataType

source§

fn from(v: String) -> Self

Converts to this type from the input type.
source§

impl From<bool> for DataType

source§

fn from(v: bool) -> Self

Converts to this type from the input type.
source§

impl From<f64> for DataType

source§

fn from(v: f64) -> Self

Converts to this type from the input type.
source§

impl From<i64> for DataType

source§

fn from(v: i64) -> Self

Converts to this type from the input type.
source§

impl PartialEq<DataType> for DataType

source§

fn eq(&self, other: &DataType) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<bool> for DataType

source§

fn eq(&self, other: &bool) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<f64> for DataType

source§

fn eq(&self, other: &f64) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<i64> for DataType

source§

fn eq(&self, other: &i64) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<str> for DataType

source§

fn eq(&self, other: &str) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> ToCellDeserializer<'a> for DataType

§

type Deserializer = DataTypeDeserializer<'a>

The deserializer.
source§

fn to_cell_deserializer(&'a self, pos: (u32, u32)) -> DataTypeDeserializer<'a>

Construct a CellType deserializer at the specified position.
source§

fn is_empty(&self) -> bool

Assess if the cell is empty.
source§

impl CellType for DataType

source§

impl StructuralPartialEq for DataType

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,