pub struct ValidCacheEntry<'buffer> {
pub revision: &'buffer str,
pub version_entries: &'buffer [u8],
}
Expand description
A wrapper around a byte buffer that has been (partially) validated to be a valid cache entry
Fields§
§revision: &'buffer str
The cache entry’s revision
For git indices this will be the sha1 of the HEAD commit when the cache entry was written
For sparse indicies, this will be an HTTP header from the response that
was last written to disk, which is currently either etag: <etag>
or
last-modified: <timestamp>
version_entries: &'buffer [u8]
Portion of the buffer containing the individual version entries for the cache entry
Implementations§
Source§impl<'buffer> ValidCacheEntry<'buffer>
impl<'buffer> ValidCacheEntry<'buffer>
Sourcepub fn read(buffer: &'buffer [u8]) -> Result<Self, CacheError>
pub fn read(buffer: &'buffer [u8]) -> Result<Self, CacheError>
Attempts to read a cache entry from a block of bytes.
This can fail for a few reasons
- The cache version does not match the version(s) supported
- The index version is higher than that supported
- There is not at least 1 version entry
Sourcepub fn to_krate(
&self,
revision: Option<&str>,
) -> Result<Option<IndexKrate>, Error>
pub fn to_krate( &self, revision: Option<&str>, ) -> Result<Option<IndexKrate>, Error>
Deserializes this cache entry into a IndexKrate
If specified, the revision
will be used to ignore cache entries
that are outdated
Auto Trait Implementations§
impl<'buffer> Freeze for ValidCacheEntry<'buffer>
impl<'buffer> RefUnwindSafe for ValidCacheEntry<'buffer>
impl<'buffer> Send for ValidCacheEntry<'buffer>
impl<'buffer> Sync for ValidCacheEntry<'buffer>
impl<'buffer> Unpin for ValidCacheEntry<'buffer>
impl<'buffer> UnwindSafe for ValidCacheEntry<'buffer>
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
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>
Converts
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>
Converts
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