Skip to main content

QueryValueRef

Enum QueryValueRef 

Source
#[non_exhaustive]
pub enum QueryValueRef<'buf> { Text(&'buf str), Raw(&'buf [u8]), Number { text: &'buf str, is_integer: bool, }, Boolean(bool), IntervalDS { days: i32, hours: i32, minutes: i32, seconds: i32, fseconds: i32, }, IntervalYM { years: i32, months: i32, }, DateTime { year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, nanosecond: u32, }, TimestampTz { year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, nanosecond: u32, offset_minutes: i32, }, Owned(&'buf QueryValue), }
Expand description

A borrowed, zero-copy mirror of the hot scalar QueryValue variants whose payload lives inside the fetch decode buffer (the network response Vec<u8>). A consumer iterating a fetched row batch via the borrowed path receives QueryValueRef<'buf> values that point straight at the wire bytes — the common scalar case pays zero per-cell allocations, in contrast to the owned QueryValue path which materializes a String/Vec<u8> for every column of every row.

§What is and is not borrowed

  • Text / Raw borrow a contiguous slice of the wire buffer directly: the common single-chunk VARCHAR2/CHAR/RAW value costs nothing.
  • Number borrows the canonically reformatted decimal text. Oracle’s NUMBER is not stored as ASCII on the wire, so the borrowed path decodes it into a scratch arena the batch owns (see the borrowed fetch API) and borrows from there — still zero per-cell heap allocation, the arena grows amortized across the batch.
  • Boolean / IntervalDS / IntervalYM / DateTime are tiny Copy values decoded from the wire bytes; they never touched the heap on the owned path either.
  • The cold variants (Cursor, Object, Lob, Vector, Json) and the rare UTF-16 (NCHAR) text / synthesized ROWID / BinaryDouble cases cannot be borrowed losslessly from the wire, so they fall back to an owned boxed QueryValue (the QueryValueRef::Owned variant). These are the uncommon path; the hot scalar grid stays borrowed.

Copy + small: the enum holds borrowed scalars and small Copy payloads only (cold values live behind the boxed Owned pointer), so a row of QueryValueRef is a flat, cache-friendly slice. Convert to the owned form with QueryValueRef::to_owned_value.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Text(&'buf str)

Decoded text borrowing the wire buffer (single-chunk VARCHAR2 / CHAR / LONG that decoded as valid UTF-8).

§

Raw(&'buf [u8])

RAW / LONG_RAW bytes borrowing the wire buffer (single chunk).

§

Number

Canonical decimal text of a NUMBER, borrowed from the batch’s number scratch arena (the wire form is binary, so it is reformatted once).

Fields

§text: &'buf str
§is_integer: bool
§

Boolean(bool)

Native DB_TYPE_BOOLEAN.

§

IntervalDS

Fields

§days: i32
§hours: i32
§minutes: i32
§seconds: i32
§fseconds: i32
§

IntervalYM

Fields

§years: i32
§months: i32
§

DateTime

Fields

§year: i32
§month: u8
§day: u8
§hour: u8
§minute: u8
§second: u8
§nanosecond: u32
§

TimestampTz

Fields

§year: i32
§month: u8
§day: u8
§hour: u8
§minute: u8
§second: u8
§nanosecond: u32
§offset_minutes: i32
§

Owned(&'buf QueryValue)

Fallback for the cold / non-borrowable variants (Cursor / Object / Lob / Vector / Json, UTF-16 NCHAR text, synthesized ROWID, BinaryDouble). Boxed so the borrowed enum stays small. This is the rare path.

Implementations§

Source§

impl QueryValueRef<'_>

Source

pub fn to_owned_value(&self) -> QueryValue

Materialize an owned QueryValue from this borrowed reference, allocating exactly as the owned decode path would. Use this when a borrowed row must outlive the batch buffer (e.g. crossing the Python boundary), or to compare borrowed and owned paths in tests.

Source

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

Borrow this value as decoded text when it is a borrowed Text, otherwise None. Mirror of QueryValue::as_text for the borrowed path.

Source

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

Borrow the canonical decimal text of a NUMBER value, otherwise None. Mirror of QueryValue::as_number_text for the borrowed path. The hot case borrows the per-row number arena (zero copy). The Owned fallback only yields a borrow when the inline form spilled to boxed text; the inline numeric form has no stored &str (it never reaches Owned from the fetch path — NUMBERs are arena-resident).

Source

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

Borrow the bytes of a RAW value, otherwise None. Mirror of QueryValue::as_raw for the borrowed path.

Trait Implementations§

Source§

impl<'buf> Clone for QueryValueRef<'buf>

Source§

fn clone(&self) -> QueryValueRef<'buf>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'buf> Copy for QueryValueRef<'buf>

Source§

impl<'buf> Debug for QueryValueRef<'buf>

Source§

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

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

impl<'buf> PartialEq for QueryValueRef<'buf>

Source§

fn eq(&self, other: &QueryValueRef<'buf>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'buf> StructuralPartialEq for QueryValueRef<'buf>

Auto Trait Implementations§

§

impl<'buf> Freeze for QueryValueRef<'buf>

§

impl<'buf> RefUnwindSafe for QueryValueRef<'buf>

§

impl<'buf> Send for QueryValueRef<'buf>

§

impl<'buf> Sync for QueryValueRef<'buf>

§

impl<'buf> Unpin for QueryValueRef<'buf>

§

impl<'buf> UnsafeUnpin for QueryValueRef<'buf>

§

impl<'buf> UnwindSafe for QueryValueRef<'buf>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V