pub struct ImageStore { /* private fields */ }Expand description
Disk-based image store with in-memory index and LRU eviction.
Implementations§
Source§impl ImageStore
impl ImageStore
Sourcepub fn new(store_dir: &Path, max_size_bytes: u64) -> Result<Self>
pub fn new(store_dir: &Path, max_size_bytes: u64) -> Result<Self>
Create a new image store.
Creates the store directory if it doesn’t exist and loads any existing index from disk.
Sourcepub async fn get(&self, reference: &str) -> Option<StoredImage>
pub async fn get(&self, reference: &str) -> Option<StoredImage>
Get a stored image by reference.
Sourcepub async fn get_by_digest(&self, digest: &str) -> Option<StoredImage>
pub async fn get_by_digest(&self, digest: &str) -> Option<StoredImage>
Get a stored image by digest.
Sourcepub async fn resolve(&self, image: &str) -> Option<StoredImage>
pub async fn resolve(&self, image: &str) -> Option<StoredImage>
Resolve an image reference to a stored image.
CRI callers may address an image by an exact stored reference, by its
image id (a bare sha256:... or a name@sha256:... digest pin), or by
an unnormalized name (e.g. a tagless name that defaults to :latest).
Sourcepub async fn put(
&self,
reference: &str,
digest: &str,
source_dir: &Path,
) -> Result<StoredImage>
pub async fn put( &self, reference: &str, digest: &str, source_dir: &Path, ) -> Result<StoredImage>
Store an image from a source directory.
Copies the OCI image layout from source_dir into the store
under sha256/<digest>/.
Sourcepub async fn remove(&self, image: &str) -> Result<()>
pub async fn remove(&self, image: &str) -> Result<()>
Remove an image by reference or by image ID (digest).
The CRI RemoveImage may identify an image either by a repo
reference/tag or by its image ID (sha256:<digest>, as returned in
ImageStatus). When image does not match a stored reference key,
fall back to removing every reference that points at the matching
digest.
Sourcepub async fn list(&self) -> Vec<StoredImage>
pub async fn list(&self) -> Vec<StoredImage>
List all stored images.
Sourcepub async fn evict(&self) -> Result<Vec<String>>
pub async fn evict(&self) -> Result<Vec<String>>
Evict least-recently-used images until total size is under the limit.
Returns the references of evicted images.
Sourcepub async fn total_size(&self) -> u64
pub async fn total_size(&self) -> u64
Get total size of all stored images in bytes.
Trait Implementations§
Source§impl ImageStoreBackend for ImageStore
impl ImageStoreBackend for ImageStore
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
reference: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<StoredImage>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
reference: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<StoredImage>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
None if not cached.Source§fn get_by_digest<'life0, 'life1, 'async_trait>(
&'life0 self,
digest: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<StoredImage>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_by_digest<'life0, 'life1, 'async_trait>(
&'life0 self,
digest: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<StoredImage>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn put<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
reference: &'life1 str,
digest: &'life2 str,
source_dir: &'life3 Path,
) -> Pin<Box<dyn Future<Output = Result<StoredImage>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn put<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
reference: &'life1 str,
digest: &'life2 str,
source_dir: &'life3 Path,
) -> Pin<Box<dyn Future<Output = Result<StoredImage>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
reference: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
reference: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<StoredImage>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<StoredImage>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl !RefUnwindSafe for ImageStore
impl !UnwindSafe for ImageStore
impl Freeze for ImageStore
impl Send for ImageStore
impl Sync for ImageStore
impl Unpin for ImageStore
impl UnsafeUnpin for ImageStore
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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