pub struct IconCacheService { /* private fields */ }Expand description
图标缓存服务,提供 L1 内存缓存 + L2 文件缓存的原子操作原语。 本服务是纯缓存工具,不知道图标如何提取,也不知道 IconRequest/CacheLevel 等业务语义。 业务逻辑由 IconExtractor trait 的默认实现提供,本服务仅提供存取能力。
Implementations§
Source§impl IconCacheService
impl IconCacheService
Sourcepub fn new(cache_dir: String) -> Self
pub fn new(cache_dir: String) -> Self
创建图标缓存服务实例。 参数:cache_dir - L2 文件缓存目录路径。 返回:初始化后的 IconCacheService(尚未扫描 L2 缓存,需调用 init())。
Sourcepub fn init(&self)
pub fn init(&self)
初始化缓存服务,扫描 L2 文件缓存目录填充 cached_file_hashes。 参数:无。 返回:无。 特性:必须在 new() 之后、首次缓存操作之前调用。
Sourcepub async fn preload_l1(&self)
pub async fn preload_l1(&self)
预载 L2 文件缓存到 L1 内存。 参数:无。 返回:无。 特性:并行读取,全部完成后返回;失败条目静默跳过(查询路径会回退到按需读 L2)。
Sourcepub fn get_l1(&self, key: &str) -> Option<Vec<u8>>
pub fn get_l1(&self, key: &str) -> Option<Vec<u8>>
从 L1 内存缓存获取数据。 参数:key - 缓存键(文件名,如 “abc123.webp”)。 返回:命中返回 Some(数据),未命中返回 None。
Sourcepub fn set_l1(&self, key: &str, data: Vec<u8>)
pub fn set_l1(&self, key: &str, data: Vec<u8>)
写入 L1 内存缓存。 参数:key - 缓存键;data - 图标 WebP 数据。 返回:无。
Sourcepub fn remove_l1(&self, key: &str)
pub fn remove_l1(&self, key: &str)
移除 L1 内存缓存中的指定键(用于图标覆盖后强制刷新缓存)。 参数:key - 缓存键(文件名,如 “abc123.webp”)。 返回:无。
Sourcepub fn contains_l2(&self, key: &str) -> bool
pub fn contains_l2(&self, key: &str) -> bool
检查 L2 文件缓存中是否包含指定键。 参数:key - 缓存键(文件名)。 返回:存在返回 true。
Sourcepub async fn get_l2(&self, key: &str) -> Option<Vec<u8>>
pub async fn get_l2(&self, key: &str) -> Option<Vec<u8>>
从 L2 文件缓存读取数据。 参数:key - 缓存键(文件名)。 返回:成功返回 Some(数据),失败或不存在返回 None。
Sourcepub async fn set_l2(&self, key: &str, data: Vec<u8>)
pub async fn set_l2(&self, key: &str, data: Vec<u8>)
异步写入 L2 文件缓存。 参数:key - 缓存键(文件名);data - 图标 WebP 数据。 返回:无。 特性:写入操作在后台线程执行,不阻塞调用方;同时更新 cached_file_hashes。
Sourcepub fn update_cache_dir(&self, new_cache_dir: &str)
pub fn update_cache_dir(&self, new_cache_dir: &str)
更新图标缓存目录路径,同时清空 L1 内存缓存并重新扫描 L2。 参数:new_cache_dir - 新的图标文件缓存目录路径。 返回:无。
Auto Trait Implementations§
impl !Freeze for IconCacheService
impl !RefUnwindSafe for IconCacheService
impl Send for IconCacheService
impl Sync for IconCacheService
impl Unpin for IconCacheService
impl UnsafeUnpin for IconCacheService
impl UnwindSafe for IconCacheService
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T, C> ComponentsInto<C> for T
impl<T, C> ComponentsInto<C> for T
Source§fn components_into(self) -> C
fn components_into(self) -> C
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.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, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
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 moreSource§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more