pub struct BlobCacheConfig { /* private fields */ }Expand description
Configures one persistent crate::BlobCache.
The directory contains cache-owned files and must not be shared with unrelated data. The byte
limit bounds admitted payloads. Frequency counters tune admission accuracy; pass 0 to use the
default of 10,000.
Implementations§
Source§impl BlobCacheConfig
impl BlobCacheConfig
Sourcepub fn new(
directory: impl Into<PathBuf>,
max_bytes: i64,
frequency_counters: i64,
) -> Result<Self, BlobCacheError>
pub fn new( directory: impl Into<PathBuf>, max_bytes: i64, frequency_counters: i64, ) -> Result<Self, BlobCacheError>
Validates and creates a cache configuration.
§Arguments
directory- Cache-owned filesystem directory.max_bytes- Positive maximum number of payload bytes admitted to the cache.frequency_counters- Admission-policy counters, or0for the 10,000 default.
§Errors
Returns BlobCacheError::InvalidConfig when the directory is empty, the byte limit is not
positive, the counter count is negative, or the count cannot fit in usize.
§Examples
use dex_blob_cache::BlobCacheConfig;
let config = BlobCacheConfig::new("/tmp/dex-blobs", 64 * 1024 * 1024, 0)?;
assert_eq!(config.max_bytes(), 64 * 1024 * 1024);
assert_eq!(config.frequency_counters(), 10_000);Sourcepub fn frequency_counters(&self) -> usize
pub fn frequency_counters(&self) -> usize
Returns the admission-policy frequency counter count.
Trait Implementations§
Source§impl Clone for BlobCacheConfig
impl Clone for BlobCacheConfig
Source§fn clone(&self) -> BlobCacheConfig
fn clone(&self) -> BlobCacheConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for BlobCacheConfig
impl RefUnwindSafe for BlobCacheConfig
impl Send for BlobCacheConfig
impl Sync for BlobCacheConfig
impl Unpin for BlobCacheConfig
impl UnsafeUnpin for BlobCacheConfig
impl UnwindSafe for BlobCacheConfig
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
Mutably borrows from an owned value. Read more