pub struct Row { /* private fields */ }Expand description
A row of data from a query result.
Pre-computes column byte ranges for O(1) random access. Best for accessing multiple columns or accessing columns in random order.
§Example
for row in client.query("SELECT id, name, active FROM users")? {
let id = row.get_i32(0);
let name = row.get_string(1);
let active = row.get_bool(2);
println!("{:?}: {:?} (active={:?})", id, name, active);
}Implementations§
Source§impl Row
impl Row
Sourcepub fn column_count(&self) -> usize
pub fn column_count(&self) -> usize
Returns the number of columns.
Sourcepub fn get_bytes(&self, idx: usize) -> Option<&[u8]>
pub fn get_bytes(&self, idx: usize) -> Option<&[u8]>
Returns raw bytes for a column, or None if NULL.
Sourcepub fn get_i16(&self, idx: usize) -> Option<i16>
pub fn get_i16(&self, idx: usize) -> Option<i16>
Gets an i16 value. Returns None if NULL or invalid format.
Sourcepub fn get_i32(&self, idx: usize) -> Option<i32>
pub fn get_i32(&self, idx: usize) -> Option<i32>
Gets an i32 value. Returns None if NULL or invalid format.
Sourcepub fn get_i64(&self, idx: usize) -> Option<i64>
pub fn get_i64(&self, idx: usize) -> Option<i64>
Gets an i64 value. Returns None if NULL or invalid format.
Sourcepub fn get_f32(&self, idx: usize) -> Option<f32>
pub fn get_f32(&self, idx: usize) -> Option<f32>
Gets an f32 value. Returns None if NULL or invalid format.
Sourcepub fn get_f64(&self, idx: usize) -> Option<f64>
pub fn get_f64(&self, idx: usize) -> Option<f64>
Gets an f64 value. Returns None if NULL or invalid format.
Sourcepub fn get_bool(&self, idx: usize) -> Option<bool>
pub fn get_bool(&self, idx: usize) -> Option<bool>
Gets a bool value. Returns None if NULL or invalid format.
Sourcepub fn get_string(&self, idx: usize) -> Option<String>
pub fn get_string(&self, idx: usize) -> Option<String>
Gets a String value. Returns None if NULL or invalid UTF-8.
Sourcepub fn get_bytes_owned(&self, idx: usize) -> Option<Vec<u8>>
pub fn get_bytes_owned(&self, idx: usize) -> Option<Vec<u8>>
Gets raw bytes as owned Vec, decoding BYTEA hex format if needed.
Sourcepub fn get<T: FromHyperBinary>(&self, idx: usize) -> Option<T>
pub fn get<T: FromHyperBinary>(&self, idx: usize) -> Option<T>
Gets a typed value using the FromHyperBinary trait.
Returns None if the column is NULL or conversion fails.
Sourcepub fn get_by_name<T: FromHyperBinary>(&self, name: &str) -> Option<T>
pub fn get_by_name<T: FromHyperBinary>(&self, name: &str) -> Option<T>
Gets a typed value by column name.
Returns None if the column is NULL, not found, or conversion fails.
Sourcepub fn column_index(&self, name: &str) -> Result<usize>
pub fn column_index(&self, name: &str) -> Result<usize>
Returns the index of a column by name.
§Errors
Returns ErrorKind::Query with the column name in the message
if no column matches.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Row
impl RefUnwindSafe for Row
impl Send for Row
impl Sync for Row
impl Unpin for Row
impl UnsafeUnpin for Row
impl UnwindSafe for Row
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request