pub struct StatementBuilder { /* private fields */ }Expand description
Implementations§
Source§impl StatementBuilder
impl StatementBuilder
Sourcepub fn add_param<T: ToValue + ?Sized>(
self,
name: impl Into<String>,
value: &T,
) -> Self
pub fn add_param<T: ToValue + ?Sized>( self, name: impl Into<String>, value: &T, ) -> Self
Adds a parameter value to this Statement.
The parameter value is sent without an explicit type code to Spanner. This allows Spanner to automatically infer the correct data type from the SQL string of the statement. It is recommended to use untyped parameter values, unless you explicitly want Spanner to verify that the type of the parameter value is exactly the same as the type that would otherwise be inferred from the SQL string.
Sourcepub fn add_typed_param<T: ToValue + ?Sized>(
self,
name: impl Into<String>,
value: &T,
param_type: Type,
) -> Self
pub fn add_typed_param<T: ToValue + ?Sized>( self, name: impl Into<String>, value: &T, param_type: Type, ) -> Self
Adds a typed parameter value to this Statement.
The parameter value is sent with an explicit type code to Spanner. The type code must correspond with the expression in the SQL string that the query parameter is bound to.
Sourcepub fn set_request_tag(self, tag: impl Into<String>) -> Self
pub fn set_request_tag(self, tag: impl Into<String>) -> Self
Sets the request tag to use for this statement.
§Example
let statement = Statement::builder("SELECT * FROM users")
.set_request_tag("my-tag")
.build();See also: Troubleshooting with tags
Sourcepub fn set_priority(self, priority: Priority) -> Self
pub fn set_priority(self, priority: Priority) -> Self
Sets the RPC priority to use for this statement.
§Example
let statement = Statement::builder("SELECT * FROM users")
.set_priority(Priority::Low)
.build();Sourcepub fn set_directed_read_options(self, options: DirectedReadOptions) -> Self
pub fn set_directed_read_options(self, options: DirectedReadOptions) -> Self
Sets the directed read options for this statement.
let dro = DirectedReadOptions::default();
let stmt = Statement::builder("SELECT * FROM users")
.set_directed_read_options(dro)
.build();DirectedReadOptions can only be specified for a read-only transaction, otherwise Spanner returns an INVALID_ARGUMENT error.
Sourcepub fn set_query_options(self, options: QueryOptions) -> Self
pub fn set_query_options(self, options: QueryOptions) -> Self
Sets the query options to use for this statement.
§Example
let options = QueryOptions::default()
.set_optimizer_version("latest");
let statement = Statement::builder("SELECT * FROM users")
.set_query_options(options)
.build();Sourcepub fn set_query_mode(self, mode: QueryMode) -> Self
pub fn set_query_mode(self, mode: QueryMode) -> Self
Sets the query mode to use for this statement.
§Example
let statement = Statement::builder("SELECT * FROM users")
.set_query_mode(QueryMode::Plan)
.build();Sourcepub fn with_attempt_timeout(self, timeout: Duration) -> Self
pub fn with_attempt_timeout(self, timeout: Duration) -> Self
Sets the per-attempt timeout for this statement.
Sourcepub fn with_retry_policy(self, policy: impl Into<RetryPolicyArg>) -> Self
pub fn with_retry_policy(self, policy: impl Into<RetryPolicyArg>) -> Self
Sets the retry policy for this statement.
Sourcepub fn with_backoff_policy(self, policy: impl Into<BackoffPolicyArg>) -> Self
pub fn with_backoff_policy(self, policy: impl Into<BackoffPolicyArg>) -> Self
Sets the backoff policy for this statement.
Trait Implementations§
Source§impl Clone for StatementBuilder
impl Clone for StatementBuilder
Source§fn clone(&self) -> StatementBuilder
fn clone(&self) -> StatementBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StatementBuilder
impl Debug for StatementBuilder
Source§impl From<StatementBuilder> for Statement
impl From<StatementBuilder> for Statement
Source§fn from(builder: StatementBuilder) -> Self
fn from(builder: StatementBuilder) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for StatementBuilder
impl !UnwindSafe for StatementBuilder
impl Freeze for StatementBuilder
impl Send for StatementBuilder
impl Sync for StatementBuilder
impl Unpin for StatementBuilder
impl UnsafeUnpin for StatementBuilder
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
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>
T in a tonic::Request