Struct ReadOnlyCacheBuilder

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

Construct a ReadOnlyCache with this builder. The resulting cache will access each constituent cache directory in the order they were added.

The default builder is a fresh builder with no constituent cache and no consistency check function.

Implementations§

Source§

impl ReadOnlyCacheBuilder

Source

pub fn new() -> Self

Returns a fresh empty builder.

Source

pub fn consistency_checker( &mut self, checker: impl Fn(&mut File, &mut File) -> Result<()> + Sync + Send + RefUnwindSafe + UnwindSafe + Sized + 'static, ) -> &mut Self

Sets the consistency checker function: when the function is provided, the ReadOnlyCache will keep searching after the first cache hit, and compare subsequent hits with the first one by calling checker. The checker function should return Ok(()) if the two files are compatible (identical), and Err otherwise.

Kismet will propagate the error on mismatch.

Source

pub fn byte_equality_checker(&mut self) -> &mut Self

Sets the consistency checker function to crate::byte_equality_checker: the contents of all cache hits must be bytewise identical, without considering any metadata.

Source

pub fn panicking_byte_equality_checker(&mut self) -> &mut Self

Sets the consistency checker function to crate::panicking_byte_equality_checker: the contents of all cache hits must be bytewise identical, without considering any metadata, and the call will panic on mismatch.

Source

pub fn clear_consistency_checker(&mut self) -> &mut Self

Removes the consistency checker function, if any.

Source

pub fn arc_consistency_checker( &mut self, checker: Option<Arc<dyn Fn(&mut File, &mut File) -> Result<()> + Sync + Send + RefUnwindSafe + UnwindSafe>>, ) -> &mut Self

Sets the consistency checker function. None clears the checker function. See ReadOnlyCacheBuilder::consistency_checker.

Source

pub fn cache(&mut self, path: impl AsRef<Path>, num_shards: usize) -> &mut Self

Adds a new cache directory at path to the end of the cache builder’s search list.

Adds a plain cache directory if num_shards <= 1, and an actual sharded directory otherwise.

Source

pub fn plain(&mut self, path: impl AsRef<Path>) -> &mut Self

Adds a new plain cache directory at path to the end of the cache builder’s search list. A plain cache directory is merely a directory of files where the files’ names match their key’s name.

Source

pub fn plain_caches<P>( &mut self, paths: impl IntoIterator<Item = P>, ) -> &mut Self
where P: AsRef<Path>,

Adds a new plain cache directory for each path in paths. The caches are appended in order to the end of the cache builder’s search list.

Source

pub fn sharded( &mut self, path: impl AsRef<Path>, num_shards: usize, ) -> &mut Self

Adds a new sharded cache directory at path to the end of the cache builder’s search list.

Source

pub fn take(&mut self) -> Self

Returns the contents of self as a fresh value; self is reset to the default empty builder state. This makes it possible to declare simple configurations in a single expression, with .take().build().

Source

pub fn build(self) -> ReadOnlyCache

Returns a fresh ReadOnlyCache for the builder’s search list of constituent cache directories.

Trait Implementations§

Source§

impl Debug for ReadOnlyCacheBuilder

Source§

fn fmt(&self, __f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ReadOnlyCacheBuilder

Source§

fn default() -> ReadOnlyCacheBuilder

Returns the “default value” for a type. Read more

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, 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, 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