pub struct HeaderCacheEntry {
pub schema_version: u32,
pub repo: String,
pub revision: String,
pub filename: String,
pub etag: String,
pub cached_at: SystemTime,
pub info: SafetensorsHeaderInfo,
}Expand description
On-disk cache entry for one parsed remote header.
Fields§
§schema_version: u32Cache schema version. Compared against SCHEMA_VERSION.
repo: StringThe repository identifier this entry was parsed for.
revision: StringThe resolved revision (branch, tag, or commit SHA — "main" when
the caller did not pin one).
filename: StringThe filename within the repo.
etag: StringThe remote etag the header was fetched against. A different etag on a later call means the upstream file changed, invalidating this entry.
cached_at: SystemTimeWhen this entry was written — feeds the Source: cached header (age: ...) display line.
info: SafetensorsHeaderInfoThe parsed header.
Implementations§
Source§impl HeaderCacheEntry
impl HeaderCacheEntry
Sourcepub fn new(
repo: String,
revision: String,
filename: String,
etag: String,
info: SafetensorsHeaderInfo,
) -> Self
pub fn new( repo: String, revision: String, filename: String, etag: String, info: SafetensorsHeaderInfo, ) -> Self
Builds a fresh entry for a header just parsed remotely.
Sourcepub fn is_compatible_with(
&self,
repo: &str,
revision: &str,
filename: &str,
etag: &str,
) -> bool
pub fn is_compatible_with( &self, repo: &str, revision: &str, filename: &str, etag: &str, ) -> bool
Returns true when this entry is still valid for the given
request — every field but cached_at/info must match exactly.
Sourcepub async fn load(
path: &Path,
repo: &str,
revision: &str,
filename: &str,
etag: &str,
) -> Option<Self>
pub async fn load( path: &Path, repo: &str, revision: &str, filename: &str, etag: &str, ) -> Option<Self>
Reads and validates the cache entry at path against the given
request.
Returns None on a cache miss for any reason — an absent file,
unparseable JSON, or a stale/mismatched entry — never an error; the
caller falls back to a normal remote fetch either way.
Sourcepub async fn save_atomic(&self, path: &Path) -> Result<(), FetchError>
pub async fn save_atomic(&self, path: &Path) -> Result<(), FetchError>
Writes this entry to path atomically (write-tmp + rename), via the
shared atomic_write::write_atomic helper — the same
durability pattern chunked_state::ChunkedState::save_atomic
uses. Creates the parent directory (.hf-fm-header-cache/) if it
does not exist yet — the first --cache-headers call against a repo
that was never downloaded.
§Errors
Returns FetchError::Io on filesystem errors during the parent
directory creation, the temp write, or the rename.
Trait Implementations§
Source§impl Clone for HeaderCacheEntry
impl Clone for HeaderCacheEntry
Source§fn clone(&self) -> HeaderCacheEntry
fn clone(&self) -> HeaderCacheEntry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HeaderCacheEntry
impl Debug for HeaderCacheEntry
Source§impl<'de> Deserialize<'de> for HeaderCacheEntry
impl<'de> Deserialize<'de> for HeaderCacheEntry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for HeaderCacheEntry
impl RefUnwindSafe for HeaderCacheEntry
impl Send for HeaderCacheEntry
impl Sync for HeaderCacheEntry
impl Unpin for HeaderCacheEntry
impl UnsafeUnpin for HeaderCacheEntry
impl UnwindSafe for HeaderCacheEntry
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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> ⓘ
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> ⓘ
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