CacheItems

Struct CacheItems 

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

Records data about the cached sources and where their artefacts are within a Cache.

When a Source is fetched, insert its Artefact into a cache to avoid repeatedly fetching the same source definition.

When fetching a source, check the cache subdirectory to use with CacheItems::relative_path.

Implementations§

Source§

impl CacheItems

Source

pub fn new() -> Self

Create an empty collection.

Source

pub fn get(&self, source: &Source) -> Option<&Artefact>

Retrieves a cached artefact for the given source, if it exists.

Source

pub fn contains(&self, source: &Source) -> bool

Check whether the cache contains the given source.

Source

pub fn insert(&mut self, artefact: Artefact)

Cache an artefact and return the digest of the Source which created it. Replaces any previous value for this source.

Source

pub fn remove(&mut self, source: &Source) -> Option<Artefact>

Removes a cached value for the given source, returning it if it existed.

Source

pub fn values(&self) -> impl Iterator<Item = &Artefact>

Returns an iterator over the cached values.

Source

pub fn is_empty(&self) -> bool

Checks if the cache is empty.

Source

pub fn len(&self) -> usize

Returns the number of cached values.

Source

pub fn relative_path<S: AsRef<Source>>(&self, source: S) -> RelCacheDir

Get the relative path for a source within a cache directory

Trait Implementations§

Source§

impl Debug for CacheItems

Source§

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

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

impl Default for CacheItems

Source§

fn default() -> CacheItems

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

impl<'de> Deserialize<'de> for CacheItems

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'a> IntoIterator for &'a CacheItems

Source§

type Item = (&'a Digest, &'a Artefact)

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, Digest, Artefact>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl IntoIterator for CacheItems

Source§

type Item = (Digest, Artefact)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<Digest, Artefact>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for CacheItems

Source§

fn eq(&self, other: &CacheItems) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for CacheItems

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for CacheItems

Source§

impl StructuralPartialEq for CacheItems

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> 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,