#[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/Rawborrow a contiguous slice of the wire buffer directly: the common single-chunkVARCHAR2/CHAR/RAWvalue costs nothing.Numberborrows the canonically reformatted decimal text. Oracle’sNUMBERis 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/DateTimeare tinyCopyvalues 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 / synthesizedROWID/BinaryDoublecases cannot be borrowed losslessly from the wire, so they fall back to an owned boxedQueryValue(theQueryValueRef::Ownedvariant). 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
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).
Boolean(bool)
Native DB_TYPE_BOOLEAN.
IntervalDS
IntervalYM
DateTime
TimestampTz
Fields
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<'_>
impl QueryValueRef<'_>
Sourcepub fn to_owned_value(&self) -> QueryValue
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.
Sourcepub fn as_text(&self) -> Option<&str>
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.
Sourcepub fn as_number_text(&self) -> Option<&str>
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).
Sourcepub fn as_raw(&self) -> Option<&[u8]>
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>
impl<'buf> Clone for QueryValueRef<'buf>
Source§fn clone(&self) -> QueryValueRef<'buf>
fn clone(&self) -> QueryValueRef<'buf>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<'buf> Copy for QueryValueRef<'buf>
Source§impl<'buf> Debug for QueryValueRef<'buf>
impl<'buf> Debug for QueryValueRef<'buf>
Source§impl<'buf> PartialEq for QueryValueRef<'buf>
impl<'buf> PartialEq for QueryValueRef<'buf>
Source§fn eq(&self, other: &QueryValueRef<'buf>) -> bool
fn eq(&self, other: &QueryValueRef<'buf>) -> bool
self and other values to be equal, and is used by ==.