pub struct SpannerDatabase;Implementations§
Source§impl SpannerDatabase
impl SpannerDatabase
Sourcepub async fn connect(database: &str) -> Result<DatabaseConnection, DbErr>
pub async fn connect(database: &str) -> Result<DatabaseConnection, DbErr>
Connect to an existing Spanner database
Automatically detects the environment:
- If
SPANNER_EMULATOR_HOSTis set, connects without authentication - Otherwise, uses Application Default Credentials (ADC) for authentication
ADC discovers credentials from (in order):
GOOGLE_APPLICATION_CREDENTIALSenvironment variable (service account JSON)gcloud auth application-default login(local development)- GCE/GKE metadata server (when running on Google Cloud)
Sourcepub async fn connect_with_config(
database: &str,
config: ClientConfig,
) -> Result<DatabaseConnection, DbErr>
pub async fn connect_with_config( database: &str, config: ClientConfig, ) -> Result<DatabaseConnection, DbErr>
Connect to an existing Spanner database with custom configuration
Sourcepub async fn connect_with_emulator(
database: &str,
) -> Result<DatabaseConnection, DbErr>
pub async fn connect_with_emulator( database: &str, ) -> Result<DatabaseConnection, DbErr>
Connect to Spanner using the local emulator
Sourcepub async fn connect_with_emulator_host(
database: &str,
emulator_host: &str,
) -> Result<DatabaseConnection, DbErr>
pub async fn connect_with_emulator_host( database: &str, emulator_host: &str, ) -> Result<DatabaseConnection, DbErr>
Connect to Spanner using a custom emulator host
Sourcepub async fn connect_or_create_with_emulator(
database: &str,
options: CreateOptions,
) -> Result<DatabaseConnection, DbErr>
pub async fn connect_or_create_with_emulator( database: &str, options: CreateOptions, ) -> Result<DatabaseConnection, DbErr>
Connect to Spanner emulator, creating instance and/or database if they don’t exist
Note: This function only works with the Spanner emulator (localhost:9010).
It will fail if SPANNER_EMULATOR_HOST is not set.
§Example
ⓘ
use sea_orm_spanner::{SpannerDatabase, CreateOptions};
// Create database if not exists (default behavior)
let db = SpannerDatabase::connect_or_create_with_emulator(
"projects/test/instances/test/databases/test",
CreateOptions::default(),
).await?;
// Also create instance if not exists
let db = SpannerDatabase::connect_or_create_with_emulator(
"projects/test/instances/test/databases/test",
CreateOptions::new().with_instance_creation(),
).await?;Sourcepub async fn connect_or_create_with_emulator_host(
database: &str,
emulator_host: &str,
options: CreateOptions,
) -> Result<DatabaseConnection, DbErr>
pub async fn connect_or_create_with_emulator_host( database: &str, emulator_host: &str, options: CreateOptions, ) -> Result<DatabaseConnection, DbErr>
Connect to Spanner emulator at custom host, creating instance/database if needed
Note: This function only works with the Spanner emulator.
Auto Trait Implementations§
impl Freeze for SpannerDatabase
impl RefUnwindSafe for SpannerDatabase
impl Send for SpannerDatabase
impl Sync for SpannerDatabase
impl Unpin for SpannerDatabase
impl UnsafeUnpin for SpannerDatabase
impl UnwindSafe for SpannerDatabase
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
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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