Struct google_cloud_spanner::key::Key [−][src]
pub struct Key { /* fields omitted */ }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. - chrono::NaiveDateTime and Optionchrono::NaiveDateTime are mapped to Cloud Spanner’s TIMESTAMP type.
- chrono::DateTime and Optionchrono::DateTime 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
one creates new Key
Examples
use google_cloud_spanner::key::Key;
use google_cloud_spanner::statement::ToKind;
let key1 = Key::key(&"a");
let key2 = Key::key(&1);Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Key
impl UnwindSafe for Key
Blanket Implementations
Mutably borrows from an owned value. Read more
Wrap the input message T in a tonic::Request
pub fn vzip(self) -> V
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more
