Struct CdnCache

Source
pub struct CdnCache { /* private fields */ }
Expand description

Cache for CDN content following the standard CDN directory structure

Implementations§

Source§

impl CdnCache

Source

pub async fn new() -> Result<Self>

Create a new CDN cache

Source

pub async fn for_product(product: &str) -> Result<Self>

Create a CDN cache for a specific product

Source

pub async fn with_base_dir(base_dir: PathBuf) -> Result<Self>

Create a CDN cache with a custom base directory

Source

pub async fn with_cdn_path(cdn_path: &str) -> Result<Self>

Create a CDN cache with a specific CDN path

Source

pub fn set_cdn_path(&mut self, cdn_path: Option<String>)

Set the CDN path for this cache

Source

pub fn config_dir(&self) -> PathBuf

Get the config cache directory

Source

pub fn data_dir(&self) -> PathBuf

Get the data cache directory

Source

pub fn patch_dir(&self) -> PathBuf

Get the patch cache directory

Source

pub fn config_path(&self, hash: &str) -> PathBuf

Construct a config cache path from a hash

Follows CDN structure: config/{first2}/{next2}/{hash}

Source

pub fn data_path(&self, hash: &str) -> PathBuf

Construct a data cache path from a hash

Follows CDN structure: data/{first2}/{next2}/{hash}

Source

pub fn patch_path(&self, hash: &str) -> PathBuf

Construct a patch cache path from a hash

Follows CDN structure: patch/{first2}/{next2}/{hash}

Source

pub fn index_path(&self, hash: &str) -> PathBuf

Construct an index cache path from a hash

Follows CDN structure: data/{first2}/{next2}/{hash}.index

Source

pub async fn has_config(&self, hash: &str) -> bool

Check if a config exists in cache

Source

pub async fn has_data(&self, hash: &str) -> bool

Check if data exists in cache

Source

pub async fn has_patch(&self, hash: &str) -> bool

Check if a patch exists in cache

Source

pub async fn has_index(&self, hash: &str) -> bool

Check if an index exists in cache

Source

pub async fn write_config(&self, hash: &str, data: &[u8]) -> Result<()>

Write config data to cache

Source

pub async fn write_data(&self, hash: &str, data: &[u8]) -> Result<()>

Write data to cache

Source

pub async fn write_patch(&self, hash: &str, data: &[u8]) -> Result<()>

Write patch data to cache

Source

pub async fn write_index(&self, hash: &str, data: &[u8]) -> Result<()>

Write index to cache

Source

pub async fn read_config(&self, hash: &str) -> Result<Vec<u8>>

Read config from cache

Source

pub async fn read_data(&self, hash: &str) -> Result<Vec<u8>>

Read data from cache

Source

pub async fn read_patch(&self, hash: &str) -> Result<Vec<u8>>

Read patch from cache

Source

pub async fn read_index(&self, hash: &str) -> Result<Vec<u8>>

Read index from cache

Source

pub async fn open_data(&self, hash: &str) -> Result<File>

Stream read data from cache

Returns a file handle for efficient streaming

Source

pub async fn data_size(&self, hash: &str) -> Result<u64>

Get data size without reading it

Source

pub fn base_dir(&self) -> &PathBuf

Get the base directory of this cache

Source

pub fn cdn_path(&self) -> Option<&str>

Get the CDN path if set

Source

pub async fn write_configs_batch( &self, entries: &[(String, Vec<u8>)], ) -> Result<()>

Write multiple config files in parallel

Source

pub async fn write_data_batch( &self, entries: &[(String, Vec<u8>)], ) -> Result<()>

Write multiple data files in parallel

Source

pub async fn read_configs_batch( &self, hashes: &[String], ) -> Vec<Result<Vec<u8>>>

Read multiple config files in parallel

Source

pub async fn read_data_batch(&self, hashes: &[String]) -> Vec<Result<Vec<u8>>>

Read multiple data files in parallel

Source

pub async fn has_configs_batch(&self, hashes: &[String]) -> Vec<bool>

Check existence of multiple configs in parallel

Source

pub async fn has_data_batch(&self, hashes: &[String]) -> Vec<bool>

Check existence of multiple data files in parallel

Source

pub async fn data_sizes_batch(&self, hashes: &[String]) -> Vec<Result<u64>>

Get sizes of multiple data files in parallel

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,