#![doc = include_str!("../README.md")]
#![warn(missing_docs)]
mod args;
mod cache;
mod extractor;
mod upstream;
pub use args::{Arg, Args, Skipped};
#[diagnostic::on_unimplemented(
message = "`{Self}` cannot be used as a skipped field in `#[derive(CacheableResponse)]`",
note = "skipped fields are not stored in cache and are reconstructed using `Default::default()` on cache hit",
note = "either implement `Default` for `{Self}` or remove the `#[cacheable_response(skip)]` attribute"
)]
pub trait SkippedFieldDefault {
fn skipped_default() -> Self;
}
impl<T: Default> SkippedFieldDefault for T {
fn skipped_default() -> Self {
Self::default()
}
}
#[diagnostic::on_unimplemented(
message = "`{Self}` cannot be used as a cached field in `#[derive(CacheableResponse)]`",
note = "non-skipped fields are stored in cache and must implement `Clone` for cache storage",
note = "either implement `Clone` for `{Self}` or add the `#[cacheable_response(skip)]` attribute"
)]
pub trait CachedFieldClone {
fn cached_clone(&self) -> Self;
}
impl<T: Clone> CachedFieldClone for T {
fn cached_clone(&self) -> Self {
self.clone()
}
}
pub use cache::{
Cache, CacheAccess, CacheBuilder, NoBackend, NoContext, NoPolicy, WithBackend, WithContext,
WithPolicy,
};
pub use extractor::{FnExtractor, KeyExtract};
pub use upstream::FnUpstream;
#[cfg(feature = "derive")]
pub use hitbox_derive::{CacheableRequest, CacheableResponse, KeyExtract, cached};
pub mod prelude {
pub use crate::{Arg, Args, Cache, FnExtractor, FnUpstream, KeyExtract, Skipped};
#[cfg(feature = "derive")]
pub use hitbox_derive::{CacheableRequest, CacheableResponse, cached};
pub use hitbox::KeyPart;
pub use hitbox::policy::PolicyConfig;
pub use hitbox::{CacheContext, CacheStatus, ResponseSource};
}