package cache import ( "bytes" "io" "edge-infra.dev/pkg/f8n/warehouse/oci/layer" ) // cachingLayer wraps access to v1.Layer with a [Cache]. Implements v1.Layer type cachingLayer struct { layer.Layer cache *LazyCache data []byte } // Layer returns a new v1.Layer whose contents will be read from a [Cache] if found, falling // back to fetching from remote if not found func Layer(l layer.Layer, c *LazyCache, data []byte) layer.Layer { return &cachingLayer{ Layer: l, cache: c, data: data, } } func (c *cachingLayer) Compressed() (io.ReadCloser, error) { // TODO(dk185217): make sense of compressed vs uncompressed / digest vs diffid return io.NopCloser(bytes.NewReader(c.data)), nil } func (c *cachingLayer) Uncompressed() (io.ReadCloser, error) { return io.NopCloser(bytes.NewReader(c.data)), nil }