Value

Enum Value 

Source
pub enum Value {
Show 15 variants Null, String(String), Bytes(Vec<u8>), Integer(i64), Float(f64), Number(OracleNumber), Date(OracleDate), Timestamp(OracleTimestamp), RowId(RowId), Boolean(bool), Lob(LobValue), Json(Value), Vector(OracleVector), Cursor(RefCursor), Collection(DbObject),
}
Expand description

Represents a value from an Oracle column.

This enum covers all the data types that can be returned from Oracle queries. Values can be accessed using the various as_* methods, or converted using TryFrom implementations.

§Example

use oracle_rs::Value;

fn process_value(value: &Value) {
    match value {
        Value::Null => println!("NULL"),
        Value::String(s) => println!("String: {}", s),
        Value::Integer(i) => println!("Integer: {}", i),
        Value::Float(f) => println!("Float: {}", f),
        _ => println!("Other type"),
    }
}

§Type Conversions

Values can be converted to Rust types using the accessor methods:

use oracle_rs::Value;

let value = Value::Integer(42);
let num: i64 = value.as_i64().unwrap();
assert_eq!(num, 42);

Variants§

§

Null

NULL value

§

String(String)

String value (VARCHAR2, CHAR, CLOB as string)

§

Bytes(Vec<u8>)

Byte array (RAW, BLOB as bytes)

§

Integer(i64)

Integer value (NUMBER that fits in i64)

§

Float(f64)

Floating point value (NUMBER, BINARY_FLOAT, BINARY_DOUBLE)

§

Number(OracleNumber)

Oracle NUMBER as string (for full precision)

§

Date(OracleDate)

Date value

§

Timestamp(OracleTimestamp)

Timestamp value (with optional timezone)

§

RowId(RowId)

ROWID value

§

Boolean(bool)

Boolean value

§

Lob(LobValue)

LOB value (CLOB, BLOB, BFILE)

§

Json(Value)

JSON value (Oracle 21c+, stored as OSON binary format)

§

Vector(OracleVector)

Vector value (Oracle 23ai+, for AI/ML embeddings)

§

Cursor(RefCursor)

REF CURSOR value (SYS_REFCURSOR from PL/SQL) Contains cursor metadata that can be used for fetching rows

§

Collection(DbObject)

Collection value (VARRAY, Nested Table) Contains the collection type name and elements

Implementations§

Source§

impl Value

Source

pub fn is_null(&self) -> bool

Check if this value is NULL

Source

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

Try to get as a string reference

Source

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

Try to get as an integer

Source

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

Try to get as a float

Source

pub fn as_bytes(&self) -> Option<&[u8]>

Try to get as bytes

Source

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

Try to get as a boolean

Source

pub fn as_date(&self) -> Option<&OracleDate>

Try to get as a date

Source

pub fn as_timestamp(&self) -> Option<&OracleTimestamp>

Try to get as a timestamp

Source

pub fn as_json(&self) -> Option<&Value>

Try to get as a JSON value

Source

pub fn as_vector(&self) -> Option<&OracleVector>

Try to get as a vector

Source

pub fn as_cursor(&self) -> Option<&RefCursor>

Try to get as a REF CURSOR

Source

pub fn as_cursor_id(&self) -> Option<u16>

Try to get cursor ID (for REF CURSOR)

Source

pub fn as_collection(&self) -> Option<&DbObject>

Try to get as a collection (VARRAY, Nested Table)

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

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

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

impl Display for Value

Source§

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

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

impl From<&[u8]> for Value

Source§

fn from(v: &[u8]) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for Value

Source§

fn from(v: &str) -> Self

Converts to this type from the input type.
Source§

impl From<DbObject> for Value

Source§

fn from(v: DbObject) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<Value>> From<Option<T>> for Value

Source§

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

Converts to this type from the input type.
Source§

impl From<OracleVector> for Value

Source§

fn from(v: OracleVector) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Value

Source§

fn from(v: String) -> Self

Converts to this type from the input type.
Source§

impl From<Value> for BindParam

Source§

fn from(value: Value) -> Self

Converts to this type from the input type.
Source§

impl From<Value> for Value

Source§

fn from(v: Value) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<f32>> for Value

Source§

fn from(v: Vec<f32>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<f64>> for Value

Source§

fn from(v: Vec<f64>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for Value

Source§

fn from(v: Vec<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Value

Source§

fn from(v: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Value

Source§

fn from(v: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Value

Source§

fn from(v: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Value

Source§

fn from(v: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Value

Source§

fn from(v: i64) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnwindSafe for Value

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

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

§

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> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

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

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

§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more