pub struct BinaryCacheStore { /* private fields */ }Expand description
A read-only binary cache store accessed over HTTP.
Implementations§
Source§impl BinaryCacheStore
impl BinaryCacheStore
Sourcepub fn builder(base_url: &str) -> BinaryCacheStoreBuilder
pub fn builder(base_url: &str) -> BinaryCacheStoreBuilder
Create a builder for a binary cache store with the given base URL.
Sourcepub fn new(base_url: &str, trusted_keys: Vec<String>) -> Self
pub fn new(base_url: &str, trusted_keys: Vec<String>) -> Self
Create a new binary cache client with default HTTP backend.
Sourcepub fn with_http_client(
base_url: &str,
trusted_keys: Vec<String>,
client: Box<dyn HttpClient>,
) -> Self
pub fn with_http_client( base_url: &str, trusted_keys: Vec<String>, client: Box<dyn HttpClient>, ) -> Self
Create a new binary cache client with a custom HTTP backend.
Sourcepub async fn fetch_narinfo(&self, hash: &str) -> StoreResult<Option<NarInfo>>
pub async fn fetch_narinfo(&self, hash: &str) -> StoreResult<Option<NarInfo>>
Fetch NarInfo for a store path hash.
Sourcepub fn base_url(&self) -> &str
pub fn base_url(&self) -> &str
Return the base URL of this binary cache (without trailing slash).
Sourcepub fn trusted_keys(&self) -> &[String]
pub fn trusted_keys(&self) -> &[String]
Return the trusted public keys used for signature verification.
Sourcepub fn auth_header(&self) -> Option<(&str, &str)>
pub fn auth_header(&self) -> Option<(&str, &str)>
Return the configured authorization header, if any.
Sourcepub async fn fetch_nar(&self, url_path: &str) -> StoreResult<Vec<u8>>
pub async fn fetch_nar(&self, url_path: &str) -> StoreResult<Vec<u8>>
Download a NAR file from the cache.
Sourcepub fn verify_narinfo_signatures(
narinfo: &NarInfo,
trusted_keys: &[String],
) -> StoreResult<bool>
pub fn verify_narinfo_signatures( narinfo: &NarInfo, trusted_keys: &[String], ) -> StoreResult<bool>
Verify that a NarInfo has at least one valid signature from the trusted keys.
The NarInfo fingerprint is: 1;{storePath};{narHash};{narSize};{sortedReferences}.
Each signature in the NarInfo is in keyname:base64sig format. Each trusted key
is in keyname:base64pubkey format.
Returns Ok(true) if at least one signature matches a trusted key,
Ok(false) if no trusted keys are provided or no signatures match.
Trait Implementations§
Source§impl Store for BinaryCacheStore
impl Store for BinaryCacheStore
Source§fn query_path_info<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 StorePath,
) -> Pin<Box<dyn Future<Output = StoreResult<Option<PathInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn query_path_info<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 StorePath,
) -> Pin<Box<dyn Future<Output = StoreResult<Option<PathInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn is_valid_path<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 StorePath,
) -> Pin<Box<dyn Future<Output = StoreResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn is_valid_path<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 StorePath,
) -> Pin<Box<dyn Future<Output = StoreResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn query_all_valid_paths<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<StorePath>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn query_all_valid_paths<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<StorePath>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn query_references<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 StorePath,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<StorePath>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn query_references<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 StorePath,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<StorePath>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn compute_closure<'life0, 'life1, 'async_trait>(
&'life0 self,
roots: &'life1 [StorePath],
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<StorePath>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn compute_closure<'life0, 'life1, 'async_trait>(
&'life0 self,
roots: &'life1 [StorePath],
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<StorePath>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn collect_garbage<'life0, 'life1, 'async_trait>(
&'life0 self,
_options: &'life1 GcOptions,
) -> Pin<Box<dyn Future<Output = StoreResult<GcResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn collect_garbage<'life0, 'life1, 'async_trait>(
&'life0 self,
_options: &'life1 GcOptions,
) -> Pin<Box<dyn Future<Output = StoreResult<GcResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn add_to_store<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_name: &'life1 str,
_nar_data: &'life2 [u8],
_references: &'life3 [String],
) -> Pin<Box<dyn Future<Output = StoreResult<PathInfo>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn add_to_store<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_name: &'life1 str,
_nar_data: &'life2 [u8],
_references: &'life3 [String],
) -> Pin<Box<dyn Future<Output = StoreResult<PathInfo>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§fn register_path<'life0, 'life1, 'async_trait>(
&'life0 self,
_info: &'life1 PathInfo,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn register_path<'life0, 'life1, 'async_trait>(
&'life0 self,
_info: &'life1 PathInfo,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn add_signatures<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_path: &'life1 StorePath,
_signatures: &'life2 [String],
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn add_signatures<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_path: &'life1 StorePath,
_signatures: &'life2 [String],
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn query_referrers<'life0, 'life1, 'async_trait>(
&'life0 self,
_path: &'life1 StorePath,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<StorePath>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn query_referrers<'life0, 'life1, 'async_trait>(
&'life0 self,
_path: &'life1 StorePath,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<StorePath>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn verify_store<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StoreResult<VerifyResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn verify_store<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StoreResult<VerifyResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn delete_path<'life0, 'life1, 'async_trait>(
&'life0 self,
_path: &'life1 StorePath,
) -> Pin<Box<dyn Future<Output = StoreResult<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_path<'life0, 'life1, 'async_trait>(
&'life0 self,
_path: &'life1 StorePath,
) -> Pin<Box<dyn Future<Output = StoreResult<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn optimise_store<'life0, 'async_trait>(
&'life0 self,
_dry_run: bool,
) -> Pin<Box<dyn Future<Output = StoreResult<OptimiseResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn optimise_store<'life0, 'async_trait>(
&'life0 self,
_dry_run: bool,
) -> Pin<Box<dyn Future<Output = StoreResult<OptimiseResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl !RefUnwindSafe for BinaryCacheStore
impl !UnwindSafe for BinaryCacheStore
impl Freeze for BinaryCacheStore
impl Send for BinaryCacheStore
impl Sync for BinaryCacheStore
impl Unpin for BinaryCacheStore
impl UnsafeUnpin for BinaryCacheStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more