pub struct Cache { /* private fields */ }Expand description
Cache for storing previously used flake URIs.
Used for shell completions to suggest frequently used inputs.
Implementations§
Source§impl Cache
impl Cache
Sourcepub fn load() -> Self
pub fn load() -> Self
Load the cache from the default location, or return a default empty cache.
Sourcepub fn from_path(path: &Path) -> Self
pub fn from_path(path: &Path) -> Self
Load the cache from a specific file path, or return a default empty cache.
Sourcepub fn try_from_path(path: &Path) -> Result<Self>
pub fn try_from_path(path: &Path) -> Result<Self>
Try to load the cache from a specific file path.
Sourcepub fn list_uris_for_id(&self, id: &str) -> Vec<String>
pub fn list_uris_for_id(&self, id: &str) -> Vec<String>
List cached URIs for a specific input ID, sorted by hit count (most used first).
This is useful for the “change” workflow where we want to suggest URIs that were previously used for the same input ID (e.g., both the remote github: URI and a local path: URI for testing).
Sourcepub fn populate_from_inputs<'a>(
&mut self,
inputs: impl Iterator<Item = (&'a str, &'a str)>,
)
pub fn populate_from_inputs<'a>( &mut self, inputs: impl Iterator<Item = (&'a str, &'a str)>, )
Add entries for all inputs without incrementing hit counts.
This is used to populate the cache with inputs discovered while
running any command (list, change, update, etc.), not just add.
Unlike add_entry, this does NOT increment hit counts for existing
entries - it only adds new entries that don’t exist yet.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Cache
impl<'de> Deserialize<'de> for Cache
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 Cache
impl RefUnwindSafe for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl UnwindSafe for Cache
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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