pub struct PersonalCacheRoot { /* private fields */ }Expand description
Root directory of the personal thumbnail cache, usually $XDG_CACHE_HOME/thumbnails.
Implementations§
Source§impl PersonalCacheRoot
impl PersonalCacheRoot
Sourcepub fn new(path: impl AsRef<Path>) -> Result<Self>
pub fn new(path: impl AsRef<Path>) -> Result<Self>
Creates a cache root from an already resolved absolute thumbnail root path.
§Errors
Returns an error when path is not absolute.
Sourcepub fn resolve_from_env() -> Result<Self>
pub fn resolve_from_env() -> Result<Self>
Resolves the personal thumbnail cache root from the process environment.
§Errors
Returns an error when neither an absolute XDG_CACHE_HOME nor an absolute HOME fallback
is available.
Sourcepub fn resolve_from_values(
xdg_cache_home: Option<&OsStr>,
home: Option<&OsStr>,
) -> Result<Self>
pub fn resolve_from_values( xdg_cache_home: Option<&OsStr>, home: Option<&OsStr>, ) -> Result<Self>
Resolves the personal thumbnail cache root from supplied XDG values.
Relative, unset, and blank XDG_CACHE_HOME values are ignored. HOME
must be absolute when fallback is needed.
§Errors
Returns an error when the resolved thumbnail root would not be absolute.
Sourcepub fn cache_entry_path(
&self,
uri: &PersonalOriginalUri,
namespace: &CacheNamespace,
) -> PathBuf
pub fn cache_entry_path( &self, uri: &PersonalOriginalUri, namespace: &CacheNamespace, ) -> PathBuf
Computes the personal-cache path for an accepted URI and namespace without reading it.
Sourcepub fn cache_entry_handle(
&self,
uri: &PersonalOriginalUri,
namespace: &CacheNamespace,
) -> CacheEntryHandle
pub fn cache_entry_handle( &self, uri: &PersonalOriginalUri, namespace: &CacheNamespace, ) -> CacheEntryHandle
Returns a safe-removal handle for a computed personal-cache entry path.
The handle uses the same pure path calculation as Self::cache_entry_path and does not
check whether the entry currently exists. Removal still performs containment, no-follow, and
regular-file checks at deletion time.
Sourcepub fn lookup_thumbnail_path(
&self,
original: &ReadablePersonalOriginalIdentity,
size: ThumbnailSize,
) -> Result<PersonalThumbnailLookup<ThumbnailPathLookupEntry>>
pub fn lookup_thumbnail_path( &self, original: &ReadablePersonalOriginalIdentity, size: ThumbnailSize, ) -> Result<PersonalThumbnailLookup<ThumbnailPathLookupEntry>>
Returns a validated personal-cache path for integrations that must pass a filename.
The original identity must have already been confirmed readable. The candidate PNG is opened and validated before this method returns. Callers that reopen the returned path accept that another process may replace it after validation.
§Errors
Returns an error for unexpected filesystem I/O while reading the candidate or for PNG metadata parse failures after validation succeeds.
Sourcepub fn lookup_thumbnail_png_bytes(
&self,
original: &ReadablePersonalOriginalIdentity,
size: ThumbnailSize,
) -> Result<PersonalThumbnailLookup<ThumbnailPngBytesLookupEntry>>
pub fn lookup_thumbnail_png_bytes( &self, original: &ReadablePersonalOriginalIdentity, size: ThumbnailSize, ) -> Result<PersonalThumbnailLookup<ThumbnailPngBytesLookupEntry>>
Returns exact validated PNG bytes from the personal thumbnail cache.
The original identity must have already been confirmed readable.
§Errors
Returns an error for unexpected filesystem I/O while reading the candidate or for PNG metadata parse failures after validation succeeds.
Sourcepub fn lookup_thumbnail_rgba8(
&self,
original: &ReadablePersonalOriginalIdentity,
size: ThumbnailSize,
) -> Result<PersonalThumbnailLookup<ThumbnailRgba8LookupEntry>>
pub fn lookup_thumbnail_rgba8( &self, original: &ReadablePersonalOriginalIdentity, size: ThumbnailSize, ) -> Result<PersonalThumbnailLookup<ThumbnailRgba8LookupEntry>>
Returns decoded tightly packed RGBA8 pixels from the personal thumbnail cache.
The original identity must have already been confirmed readable. The returned pixels are
row-major [red, green, blue, alpha] bytes with straight alpha and stride == width * 4.
§Errors
Returns an error for unexpected filesystem I/O while reading the candidate or for PNG decoding failures after validation succeeds.
Sourcepub fn lookup_display_thumbnail_rgba8(
&self,
original: &ReadablePersonalOriginalIdentity,
size: ThumbnailSize,
) -> Result<PersonalThumbnailLookup<DisplayThumbnailRgba8LookupEntry>>
pub fn lookup_display_thumbnail_rgba8( &self, original: &ReadablePersonalOriginalIdentity, size: ThumbnailSize, ) -> Result<PersonalThumbnailLookup<DisplayThumbnailRgba8LookupEntry>>
Returns decoded RGBA8 display pixels, falling back to larger personal-cache namespaces.
The exact namespace is checked first. If it is missing, larger namespaces are checked in ascending order. The first non-missing candidate controls the result.
§Errors
Returns an error for unexpected filesystem I/O while reading the candidate or for PNG decoding failures after validation succeeds.
Sourcepub fn install_thumbnail_returning_path(
&self,
original: &ReadablePersonalOriginalIdentity,
size: ThumbnailSize,
rendered_png: &[u8],
) -> Result<InstalledThumbnailPath>
pub fn install_thumbnail_returning_path( &self, original: &ReadablePersonalOriginalIdentity, size: ThumbnailSize, rendered_png: &[u8], ) -> Result<InstalledThumbnailPath>
Normalizes rendered PNG data, atomically installs a personal-cache thumbnail, and returns its path.
§Errors
Returns an error when rendered PNG normalization fails, final thumbnail validation fails, cache directories are unavailable or insecure, or atomic installation fails.
Sourcepub fn install_thumbnail_returning_png_bytes(
&self,
original: &ReadablePersonalOriginalIdentity,
size: ThumbnailSize,
rendered_png: &[u8],
) -> Result<InstalledThumbnailPngBytes>
pub fn install_thumbnail_returning_png_bytes( &self, original: &ReadablePersonalOriginalIdentity, size: ThumbnailSize, rendered_png: &[u8], ) -> Result<InstalledThumbnailPngBytes>
Normalizes rendered PNG data, atomically installs a personal-cache thumbnail, and returns final PNG bytes.
§Errors
Returns an error when rendered PNG normalization fails, final thumbnail validation fails, cache directories are unavailable or insecure, or atomic installation fails.
Sourcepub fn install_raw_thumbnail_returning_path(
&self,
original: &ReadablePersonalOriginalIdentity,
size: ThumbnailSize,
image: RawThumbnailImage<'_>,
) -> Result<InstalledThumbnailPath>
pub fn install_raw_thumbnail_returning_path( &self, original: &ReadablePersonalOriginalIdentity, size: ThumbnailSize, image: RawThumbnailImage<'_>, ) -> Result<InstalledThumbnailPath>
Normalizes raw pixel data, atomically installs a personal-cache thumbnail, and returns its path.
§Errors
Returns an error when raw conversion or normalization fails, final thumbnail validation fails, cache directories are unavailable or insecure, or atomic installation fails.
Sourcepub fn install_raw_thumbnail_returning_png_bytes(
&self,
original: &ReadablePersonalOriginalIdentity,
size: ThumbnailSize,
image: RawThumbnailImage<'_>,
) -> Result<InstalledThumbnailPngBytes>
pub fn install_raw_thumbnail_returning_png_bytes( &self, original: &ReadablePersonalOriginalIdentity, size: ThumbnailSize, image: RawThumbnailImage<'_>, ) -> Result<InstalledThumbnailPngBytes>
Normalizes raw pixel data, atomically installs a personal-cache thumbnail, and returns final PNG bytes.
§Errors
Returns an error when raw conversion or normalization fails, final thumbnail validation fails, cache directories are unavailable or insecure, or atomic installation fails.
Sourcepub fn materialize_thumbnail_from_larger_cache_returning_path(
&self,
original: &ReadablePersonalOriginalIdentity,
size: ThumbnailSize,
) -> Result<PersonalThumbnailLookup<MaterializedThumbnailPath>>
pub fn materialize_thumbnail_from_larger_cache_returning_path( &self, original: &ReadablePersonalOriginalIdentity, size: ThumbnailSize, ) -> Result<PersonalThumbnailLookup<MaterializedThumbnailPath>>
Materializes the requested personal-cache namespace from an exact or larger personal entry.
§Errors
Returns an error when final PNG normalization, validation, or atomic installation fails.
Sourcepub fn materialize_thumbnail_from_larger_cache_returning_png_bytes(
&self,
original: &ReadablePersonalOriginalIdentity,
size: ThumbnailSize,
) -> Result<PersonalThumbnailLookup<MaterializedThumbnailPngBytes>>
pub fn materialize_thumbnail_from_larger_cache_returning_png_bytes( &self, original: &ReadablePersonalOriginalIdentity, size: ThumbnailSize, ) -> Result<PersonalThumbnailLookup<MaterializedThumbnailPngBytes>>
Materializes the requested personal-cache namespace and returns final target PNG bytes.
§Errors
Returns an error when final PNG normalization, validation, or atomic installation fails.
Materializes a shared thumbnail into this personal cache and returns the target path.
Shared repositories are read-only; this method writes only to the receiver personal cache.
§Errors
Returns an error when shared facts cannot produce required personal metadata, final PNG normalization fails, or atomic installation fails.
Materializes a shared thumbnail into this personal cache and returns final target PNG bytes.
Shared repositories are read-only; this method writes only to the receiver personal cache.
§Errors
Returns an error when shared facts cannot produce required personal metadata, final PNG normalization fails, or atomic installation fails.
Sourcepub fn write_failure_entry_returning_path(
&self,
original: &ReadablePersonalOriginalIdentity,
namespace: &FailureNamespace,
) -> Result<InstalledThumbnailPath>
pub fn write_failure_entry_returning_path( &self, original: &ReadablePersonalOriginalIdentity, namespace: &FailureNamespace, ) -> Result<InstalledThumbnailPath>
Writes a deterministic 1x1 transparent failure entry and returns its path.
§Errors
Returns an error when failure-entry PNG encoding fails, cache directories are unavailable or insecure, or atomic installation fails.
Sourcepub fn write_failure_entry_returning_png_bytes(
&self,
original: &ReadablePersonalOriginalIdentity,
namespace: &FailureNamespace,
) -> Result<InstalledThumbnailPngBytes>
pub fn write_failure_entry_returning_png_bytes( &self, original: &ReadablePersonalOriginalIdentity, namespace: &FailureNamespace, ) -> Result<InstalledThumbnailPngBytes>
Writes a deterministic 1x1 transparent failure entry and returns final PNG bytes.
§Errors
Returns an error when failure-entry PNG encoding fails, cache directories are unavailable or insecure, or atomic installation fails.
Source§impl PersonalCacheRoot
impl PersonalCacheRoot
Sourcepub fn inspect_thumbnails(
&self,
sizes: &[ThumbnailSize],
nonstandard_entry_policy: NonstandardEntryPolicy,
) -> Result<Vec<CacheEntryInspection>>
pub fn inspect_thumbnails( &self, sizes: &[ThumbnailSize], nonstandard_entry_policy: NonstandardEntryPolicy, ) -> Result<Vec<CacheEntryInspection>>
Inspects standard successful thumbnail size directories.
§Errors
Returns an error when a selected namespace directory cannot be inspected.
Sourcepub fn inspect_failure_entries(
&self,
nonstandard_entry_policy: NonstandardEntryPolicy,
) -> Result<Vec<CacheEntryInspection>>
pub fn inspect_failure_entries( &self, nonstandard_entry_policy: NonstandardEntryPolicy, ) -> Result<Vec<CacheEntryInspection>>
Inspects direct files in immediate real failure-entry namespaces.
§Errors
Returns an error when the failure root or a selected failure namespace cannot be inspected.
Trait Implementations§
Source§impl AsRef<Path> for PersonalCacheRoot
impl AsRef<Path> for PersonalCacheRoot
Source§impl Clone for PersonalCacheRoot
impl Clone for PersonalCacheRoot
Source§fn clone(&self) -> PersonalCacheRoot
fn clone(&self) -> PersonalCacheRoot
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 PersonalCacheRoot
impl Debug for PersonalCacheRoot
Source§impl Hash for PersonalCacheRoot
impl Hash for PersonalCacheRoot
Source§impl PartialEq for PersonalCacheRoot
impl PartialEq for PersonalCacheRoot
Source§fn eq(&self, other: &PersonalCacheRoot) -> bool
fn eq(&self, other: &PersonalCacheRoot) -> bool
self and other values to be equal, and is used by ==.impl Eq for PersonalCacheRoot
impl StructuralPartialEq for PersonalCacheRoot
Auto Trait Implementations§
impl Freeze for PersonalCacheRoot
impl RefUnwindSafe for PersonalCacheRoot
impl Send for PersonalCacheRoot
impl Sync for PersonalCacheRoot
impl Unpin for PersonalCacheRoot
impl UnsafeUnpin for PersonalCacheRoot
impl UnwindSafe for PersonalCacheRoot
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> 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