Skip to main content

Module r2

Module r2 

Source
Expand description

Cloudflare R2 implementation of ObjectStore over S3-compat SigV4.

Uses local_driver::s3_sign helpers for signature computation and reqwest::blocking for HTTP so the ObjectStore trait stays synchronous. Async consumers wrap calls in tokio::task::spawn_blocking.

§Endpoint

R2’s S3-compat endpoint is https://<account_id>.r2.cloudflarestorage.com. Region is always "auto". Bucket lives in the URL path: https://<account_id>.r2.cloudflarestorage.com/<bucket>/<key>.

§list_prefix

Issues GET /<bucket>?list-type=2&prefix=<encoded> (ListObjectsV2) and parses the <Key>…</Key> elements out of the XML body. Continues with &continuation-token=<…> while <IsTruncated>true</IsTruncated> so prefixes larger than the 1000-key page size return complete.

@yah:relay(R630, “Object-store correctness + tooling gaps surfaced by standing up the cr.yah.dev registry”) @yah:at(2026-07-23T03:06:57Z) @yah:status(open) @yah:next(“Both children were found while building yah-cr (the R2-backed OCI registry) on 2026-07-22 and are independent of that work — they are latent defects in shared object-store code that any caller can hit.”) @yah:next(“Start with the SigV4 child: it is a correctness bug that fails closed but silently constrains every key namespace we can use. The bucket-delete child is additive and can follow.”) @yah:gotcha(“The SigV4 defect is why cr.yah.dev stores OCI digests as sha256/ instead of the natural sha256:. That workaround is load-bearing in two files that must stay in lockstep (app/yah/cli/src/cr.rs digest_key, app/yah/workers/yah-cr/src/index.ts digestKey). If the signing bug is fixed, those can be simplified — but only together, and only with a migration for keys already written.”) @arch:see(.yah/docs/working/W175-per-publisher-prefix.md)

Structs§

ObjectMeta
One <Contents> entry from an R2 ListObjectsV2 response.
R2ObjectStore
R2-backed ObjectStore.

Constants§

R2_ACCESS_KEY_ENV
Env var fallback for the R2 access key id.
R2_ACCESS_KEY_SLOT
Keystore slot for the R2 S3 access key id.
R2_SECRET_KEY_ENV
Env var fallback for the R2 secret key.
R2_SECRET_KEY_SLOT
Keystore slot for the R2 S3 secret key.