pub struct CachedTranslation {
pub translation: String,
pub created_at: SystemTime,
pub access_count: u32,
pub last_accessed: SystemTime,
pub content_hash: u64,
pub memory_size: usize,
}
Expand description
缓存的翻译项
Fields§
§translation: String
翻译结果
created_at: SystemTime
创建时间
access_count: u32
访问次数
last_accessed: SystemTime
最后访问时间
content_hash: u64
内容哈希(用于验证)
memory_size: usize
预估内存使用
Implementations§
Source§impl CachedTranslation
impl CachedTranslation
Sourcepub fn is_expired(&self, ttl: Duration) -> bool
pub fn is_expired(&self, ttl: Duration) -> bool
是否过期
Sourcepub fn mark_accessed(&mut self)
pub fn mark_accessed(&mut self)
记录访问
Sourcepub fn access_frequency(&self) -> f64
pub fn access_frequency(&self) -> f64
获取访问频率(每分钟)
Trait Implementations§
Source§impl AsMut<CachedTranslation> for CachedTranslation
impl AsMut<CachedTranslation> for CachedTranslation
Source§fn as_mut(&mut self) -> &mut CachedTranslation
fn as_mut(&mut self) -> &mut CachedTranslation
Converts this type into a mutable reference of the (usually inferred) input type.
Source§impl AsRef<CachedTranslation> for CachedTranslation
impl AsRef<CachedTranslation> for CachedTranslation
Source§fn as_ref(&self) -> &CachedTranslation
fn as_ref(&self) -> &CachedTranslation
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl Clone for CachedTranslation
impl Clone for CachedTranslation
Source§fn clone(&self) -> CachedTranslation
fn clone(&self) -> CachedTranslation
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for CachedTranslation
impl RefUnwindSafe for CachedTranslation
impl Send for CachedTranslation
impl Sync for CachedTranslation
impl Unpin for CachedTranslation
impl UnwindSafe for CachedTranslation
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
Mutably borrows from an owned value. Read more