pub struct Key { /* private fields */ }
Expand description
A Key can be either a Cloud Spanner row’s primary key or a secondary index key. A Key can be used as:
- A primary key which uniquely identifies a Cloud Spanner row.
- A secondary index key which maps to a set of Cloud Spanner rows indexed under it.
- An endpoint of primary key/secondary index ranges; see the KeyRange type.
Rows that are identified by the Key type are outputs of read operation or targets of delete operation in a mutation. Note that for insert/update/insert_or_update/delete mutation types, although they don’t require a primary key explicitly, the column list provided must contain enough columns that can comprise a primary key.
Keys are easy to construct. For example, suppose you have a table with a primary key of username and product ID. To make a key for this table:
use google_cloud_spanner::key::Key;
let key = Key::composite(&[&"john", &16]);
See the description of Row and Mutation types for how Go types are mapped to Cloud Spanner types. For convenience, Key type supports a range of Rust types:
- i64 and Option
are mapped to Cloud Spanner’s INT64 type. - f64 and Option
are mapped to Cloud Spanner’s FLOAT64 type. - bool and Option
are mapped to Cloud Spanner’s BOOL type. - Vec
, &u8, Option<Vec > and Option<&u8> is mapped to Cloud Spanner’s BYTES type. - String, &str, Option
, Option<&str> are mapped to Cloud Spanner’s STRING type. - time::OffsetDateTime and Optiontime::OffsetDateTime are mapped to Cloud Spanner’s TIMESTAMP type.
- time::Date and Optiontime::Date are mapped to Cloud Spanner’s DATE type.
- google_cloud_spanner::value::CommitTimestamp and Option<google_cloud_spanner::value::CommitTimestamp> are mapped to Cloud Spanner’s TIMESTAMP type.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Key
impl RefUnwindSafe for Key
impl Send for Key
impl Sync for Key
impl Unpin for Key
impl UnwindSafe for Key
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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