pub struct Row { /* private fields */ }Expand description
A row in a query result.
Implementations§
Source§impl Row
impl Row
Sourcepub fn raw_values(&self) -> &[Value]
pub fn raw_values(&self) -> &[Value]
Returns the raw values of the row.
Sourcepub fn try_is_null<I: ColumnIndex>(&self, index: I) -> Result<bool>
pub fn try_is_null<I: ColumnIndex>(&self, index: I) -> Result<bool>
Returns true if the value at the specified column name or index is null.
§Example
let client = Spanner::builder().build().await?;
let db_client = client.database_client("projects/p/instances/i/databases/d").build().await?;
let transaction = db_client.single_use().build();
let mut result_set = transaction.execute_query(Statement::builder("SELECT NULL AS Age").build()).await?;
if let Some(row) = result_set.next().await {
let is_null = row?.try_is_null("Age")?;
println!("Is null: {}", is_null);
}§Arguments
index- The column name (string) or index (zero-based integer).
§Returns
Ok(bool)if the value is null or not.Err(Error)if the column name or index is invalid.
Sourcepub fn is_null<I: ColumnIndex>(&self, index: I) -> bool
pub fn is_null<I: ColumnIndex>(&self, index: I) -> bool
Returns true if the value at the specified column name or index is null, panicking on error.
§Example
let client = Spanner::builder().build().await?;
let db_client = client.database_client("projects/p/instances/i/databases/d").build().await?;
let transaction = db_client.single_use().build();
let mut result_set = transaction.execute_query(Statement::builder("SELECT NULL AS Age").build()).await?;
if let Some(row) = result_set.next().await {
let is_null = row?.is_null("Age");
println!("Is null: {}", is_null);
}This is a convenience wrapper around try_is_null.
§Panics
Panics if the column name or index is invalid.
Sourcepub fn try_get<T: FromValue, I: ColumnIndex>(&self, index: I) -> Result<T>
pub fn try_get<T: FromValue, I: ColumnIndex>(&self, index: I) -> Result<T>
Retrieves a value from the row by column name or zero-based index.
§Example
let client = Spanner::builder().build().await?;
let db_client = client.database_client("projects/p/instances/i/databases/d").build().await?;
let transaction = db_client.single_use().build();
let mut result_set = transaction.execute_query(Statement::builder("SELECT 42 AS Age").build()).await?;
if let Some(row) = result_set.next().await {
let age: i64 = row?.try_get("Age")?;
println!("Age: {}", age);
}§Arguments
index- The column name (string) or index (zero-based integer).
§Returns
Ok(T)if the value was successfully retrieved and converted to typeT.Err(Error)if:- The column name or index is invalid.
- The column value is incompatible with type
T.
Sourcepub fn get<T: FromValue, I: ColumnIndex>(&self, index: I) -> T
pub fn get<T: FromValue, I: ColumnIndex>(&self, index: I) -> T
Retrieves a value from the row by column name or zero-based index, panicking on error.
§Example
let client = Spanner::builder().build().await?;
let db_client = client.database_client("projects/p/instances/i/databases/d").build().await?;
let transaction = db_client.single_use().build();
let mut result_set = transaction.execute_query(Statement::builder("SELECT 42 AS Age").build()).await?;
if let Some(row) = result_set.next().await {
let age: i64 = row?.get("Age");
println!("Age: {}", age);
}This is a convenience wrapper around try_get.
§Panics
Panics if:
- The column name or index is invalid.
- The column value is incompatible with type
T.
Trait Implementations§
impl StructuralPartialEq for Row
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
Wrap the input message
T in a tonic::Request