Enum oci_rs::types::SqlValue [−][src]
pub enum SqlValue { VarChar(String), Char(String), Integer(i64), Float(f64), Null, Date(Date<Utc>, [u8; 7]), Timestamp(DateTime<Utc>, [u8; 11]), TimestampTz(DateTime<FixedOffset>, [u8; 13]), }
The types that support conversion from OCI to Rust types.
Variants
VarChar(String)
Anything specified as VARCHAR
or VARCHAR2
will end up here.
Char(String)
Represents CHAR
Integer(i64)
All integers regardless of their stated size are represented with this variant. e.g.
SMALLINT
and INTEGER
will both be held.
Float(f64)
All floating point types regardless of their size are represented with this variant. e.g.
REAL
and FLOAT
will both be held.
Null
Represents null values in columns.
Date(Date<Utc>, [u8; 7])
Represents a date
Timestamp(DateTime<Utc>, [u8; 11])
Represents a timestamp without time zone
TimestampTz(DateTime<FixedOffset>, [u8; 13])
Represents a timestamp with a time zone
Methods
impl SqlValue
[src]
impl SqlValue
pub fn value<T: FromSqlValue>(&self) -> Option<T>
[src]
pub fn value<T: FromSqlValue>(&self) -> Option<T>
Returns the internal value converting on the way to whichever type implements
FromSqlValue
.
It returns an Option
because conversion might not be possible.
For example converting an SqlValue::Integer
to a String
works just fine, but converting
an SqlValue::Null
to an i64 does not make sense.
Examples
use oci_rs::types::{SqlValue, ToSqlValue}; let v = SqlValue::Integer(42); let i: i64 = v.value().expect("Won't convert to an i64"); let s: String = v.value().expect("Won't convert to a String"); assert_eq!(i, 42); assert_eq!(s, "42"); let null = SqlValue::Null; let null_as_i64: Option<i64> = null.value(); assert_eq!(null_as_i64, None);
Trait Implementations
impl Debug for SqlValue
[src]
impl Debug for SqlValue
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl PartialEq for SqlValue
[src]
impl PartialEq for SqlValue
fn eq(&self, other: &SqlValue) -> bool
[src]
fn eq(&self, other: &SqlValue) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &SqlValue) -> bool
[src]
fn ne(&self, other: &SqlValue) -> bool
This method tests for !=
.
impl Clone for SqlValue
[src]
impl Clone for SqlValue