Skip to main content

proto

Function proto 

Source
pub fn proto(proto_type_fqn: impl Into<String>) -> Type
Expand description

Returns a Type representing PROTO (GoogleSQL) with the given fully qualified proto type name.

Spanner uses the fully qualified proto type name to resolve the message schema from the database’s proto bundle when binding query parameters.

§Example

use google_cloud_spanner::statement::Statement;
use google_cloud_spanner::types::proto;

// Protobuf message serialized to bytes (e.g. from `address_proto.encode_to_vec()`)
let address_payload = b"serialized-proto-address".to_vec();

let statement = Statement::builder(
    "SELECT OrderId, ShippingAddress.city FROM Orders WHERE ShippingAddress = @address",
)
.add_typed_param("address", address_payload, proto("examples.shipping.Address"))
.build();