pub struct R2ObjectStore { /* private fields */ }Expand description
R2-backed ObjectStore.
Construct with R2ObjectStore::new when keys are already in hand,
or R2ObjectStore::from_vault to pull them from the yah keystore
(with env-var fallback).
Implementations§
Source§impl R2ObjectStore
impl R2ObjectStore
Sourcepub fn new(
account_id: impl Into<String>,
bucket: impl Into<String>,
access_key: impl Into<String>,
secret_key: impl Into<String>,
) -> Result<Self, Error>
pub fn new( account_id: impl Into<String>, bucket: impl Into<String>, access_key: impl Into<String>, secret_key: impl Into<String>, ) -> Result<Self, Error>
Construct with explicit keys.
account_id is the Cloudflare account id (the subdomain in
<account_id>.r2.cloudflarestorage.com).
Sourcepub fn with_endpoint(self, endpoint: impl Into<String>) -> Self
pub fn with_endpoint(self, endpoint: impl Into<String>) -> Self
Point this store at an S3-compatible endpoint other than R2 — in
practice, the pond tier’s local MinIO (http://127.0.0.1:9000).
Everything else about the store is already endpoint-agnostic: the bucket lives in the URL path (path-style addressing, which MinIO also speaks) and SigV4 is signed against whatever host the URL names.
This exists because without it the pond rehearsal could not exercise the
read side of a publish at all. publish_to_pond uploads a directory
tree and offers no way to read an object back, so the one part of a
release that is a read-modify-write — the accumulating index.json that
https://yah.dev/releases renders from — was the one part a green local
rehearsal proved nothing about (R330-T32). A conditional-write loop that
has never run is a conditional-write loop you do not have.
The region stays "auto"; MinIO accepts it.
Sourcepub fn from_vault(
account_id: impl Into<String>,
bucket: impl Into<String>,
) -> Result<Self, Error>
pub fn from_vault( account_id: impl Into<String>, bucket: impl Into<String>, ) -> Result<Self, Error>
Construct from the yah keystore (vault), falling back to env vars.
Reads cloudflare-r2-access-key-id / cloudflare-r2-secret-key slots
(env fallback CF_R2_ACCESS_KEY_ID / CF_R2_SECRET_KEY). Returns
Error::Auth if either is missing.
Source§impl R2ObjectStore
impl R2ObjectStore
Sourcepub fn list_prefix_detailed(
&self,
prefix: &str,
) -> Result<Vec<ObjectMeta>, Error>
pub fn list_prefix_detailed( &self, prefix: &str, ) -> Result<Vec<ObjectMeta>, Error>
List objects under prefix returning key + size + last-modified.
Same paginated request as ObjectStore::list_prefix but parses the
<Size> and <LastModified> siblings of each <Key> element. Used by
the data-tab bucket viewer to render a directory-style listing.
Trait Implementations§
Source§impl Drop for R2ObjectStore
impl Drop for R2ObjectStore
Source§impl ObjectStore for R2ObjectStore
impl ObjectStore for R2ObjectStore
Source§fn locate(&self, key: &str) -> String
fn locate(&self, key: &str) -> String
key lives, in a form an operator can act on — a URL for a remote
backend, an opaque descriptor otherwise (R746-F1). Read moreSource§fn get(&self, key: &str) -> Result<Option<Vec<u8>>, Error>
fn get(&self, key: &str) -> Result<Option<Vec<u8>>, Error>
key. Returns None when the key does not exist —
NotFound is reserved for ambiguous cases (HEAD-then-GET race etc.).Source§fn head(&self, key: &str) -> Result<bool, Error>
fn head(&self, key: &str) -> Result<bool, Error>
key exists. Cheaper than get for backends that
support HEAD; the default impl falls back to get(...).is_some().Source§fn delete(&self, key: &str) -> Result<(), Error>
fn delete(&self, key: &str) -> Result<(), Error>
key. Idempotent — succeeds whether or not the key existed.