pub struct Spanner { /* private fields */ }Expand description
A client for the Spanner API.
Use this client to interact with the Spanner service.
Implementations§
Source§impl Spanner
impl Spanner
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Returns a builder for the Spanner client.
§Example
let spanner = Spanner::builder().build().await?;
let db_client = spanner
.database_client("projects/my-project/instances/my-instance/databases/my-db")
.build()
.await?;
let tx = db_client.single_use().build();
let mut rs = tx.execute_query("SELECT 1").await?;
while let Some(row) = rs.next().await {
let row = row?;
let val: i64 = row.get(0);
assert_eq!(val, 1);
}The returned builder is pre-configured with standard defaults. It automatically
detects and connects to the Spanner emulator if the SPANNER_EMULATOR_HOST
environment variable is set.
Sourcepub fn database_admin_builder(&self) -> DatabaseAdminBuilder
pub fn database_admin_builder(&self) -> DatabaseAdminBuilder
Returns a builder for the DatabaseAdmin client.
This builder is automatically pre-configured with the same endpoints, credentials,
and routing configurations as this Spanner instance.
If configured to use the Emulator (via SPANNER_EMULATOR_HOST), it maps the gRPC endpoint port
(9010) to the REST admin port (9020).
Sourcepub fn instance_admin_builder(&self) -> InstanceAdminBuilder
pub fn instance_admin_builder(&self) -> InstanceAdminBuilder
Returns a builder for the InstanceAdmin client.
This builder is automatically pre-configured with the same endpoints, credentials,
and routing configurations as this Spanner instance.
If configured to use the Emulator (via SPANNER_EMULATOR_HOST), it maps the gRPC endpoint port
(9010) to the REST admin port (9020).
Sourcepub fn database_client(
&self,
database: impl Into<String>,
) -> DatabaseClientBuilder
pub fn database_client( &self, database: impl Into<String>, ) -> DatabaseClientBuilder
Returns a new DatabaseClientBuilder for interacting with a specific database.
§Example
let spanner = Spanner::builder().build().await?;
let database_client = spanner
.database_client("projects/my-project/instances/my-instance/databases/my-db")
.build()
.await?;The returned DatabaseClient is intended to be a long-lived object and should be reused
for all operations on the database.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Spanner
impl !UnwindSafe for Spanner
impl Freeze for Spanner
impl Send for Spanner
impl Sync for Spanner
impl Unpin for Spanner
impl UnsafeUnpin for Spanner
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