pub trait ICacheEntryValidity: Send + Sync {
fn is_cacheable(&self) -> bool;
fn is_cache_still_valid(&self) -> bool;
}
#[cfg(test)]
mod tests {
use super::ICacheEntryValidity;
struct CustomValidity {
cacheable: bool,
valid: bool,
}
impl ICacheEntryValidity for CustomValidity {
fn is_cacheable(&self) -> bool {
self.cacheable
}
fn is_cache_still_valid(&self) -> bool {
self.valid
}
}
#[test]
fn supports_custom_dynamic_validity_implementations() {
let validity: &dyn ICacheEntryValidity = &CustomValidity {
cacheable: true,
valid: false,
};
assert!(validity.is_cacheable());
assert!(!validity.is_cache_still_valid());
}
}