This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
rust-bigtable is a Rust library for interfacing with Google Cloud Bigtable Data API. It uses protobuf messages converted to JSON for HTTP requests (not full gRPC) with JWT-based authentication via goauth.
# Build the library (also generates protobuf code via build.rs)
cargo build
# Run tests (doc tests only - no separate test files)
cargo test
# Check compilation without building
cargo checkbuild.rsgenerates Rust code from.protofiles inprotos/intosrc/protos/- Proto sources:
protos/google/bigtable/v2/bigtable.proto,data.proto, andprotos/google/rpc/status.proto
-
method.rs: Defines theBigTabletrait and method structs via themethod!macro. Each Bigtable API method (ReadRows, MutateRow, MutateRows, etc.) is a struct wrapping its protobuf request type. -
request.rs:BTRequest<T: BigTable>is the main request executor. It:- Forms URLs from
Tablehierarchy (Project → Instance → Table) - Converts protobuf payloads to JSON via
protobuf_json_temp - Executes HTTP requests via
curl - Returns responses as
serde_json::Value
- Forms URLs from
-
support.rs: DefinesProject,Instance, andTablestructs that form the table path hierarchy. -
wraps.rs: Higher-level wrappers (read_rows,write_rows,bulk_write_rows) that abstract away protobuf message construction. -
utils.rs: Authentication helpers (get_auth_token) and encoding utilities (encode_strfor base64). -
error.rs: UnifiedBTErrerror type aggregating errors from goauth, curl, serde, protobuf, jwt, and utf8.
- Create a
Table(withInstanceandProject) - Get auth token via
get_auth_token(credentials_path, is_file_path) - Build
BTRequestwith table and method (e.g.,ReadRows::new()) - Configure payload via
method.payload_mut().set_*() - Execute with
req.execute(&token)→ returnsserde_json::Value
goauth/smpl_jwt: Google OAuth2 / JWT authenticationprotobuf/protobuf-json-mapping: Protobuf message handling and JSON conversioncurl: HTTP clientserde_json: JSON serialization
- Project ID:
gen-lang-client-0421059902 - Instance:
test-inst - Table:
my-table - Column Family:
cf1
# Create instance
gcloud bigtable instances create test-inst \
--project=gen-lang-client-0421059902 \
--cluster=test-cluster \
--cluster-zone=us-central1-c \
--display-name="Test Instance"
# Create table with column family
cbt -project=gen-lang-client-0421059902 -instance=test-inst createtable my-table
cbt -project=gen-lang-client-0421059902 -instance=test-inst createfamily my-table cf1Requires a service account JSON key with roles/bigtable.user permission.
- Credentials file:
Rust Bigtable IAM Admin.json(gitignored) - Service account:
rustbigtable@gen-lang-client-0421059902.iam.gserviceaccount.com
Usage: get_auth_token("Rust Bigtable IAM Admin.json", true)