pub struct UseCaseBuilder<Args, T> { /* private fields */ }Expand description
Builds a registered use case. Finish with register
for serde JSON values or register_custom
with an explicit codec and comparator.
Implementations§
Source§impl<Args, T> UseCaseBuilder<Args, T>
impl<Args, T> UseCaseBuilder<Args, T>
Sourcepub fn policy(self, policy: Policy) -> Self
pub fn policy(self, policy: Policy) -> Self
Static policy captured for every call of this use case.
Sourcepub fn tracked(self, tracked: bool) -> Self
pub fn tracked(self, tracked: bool) -> Self
Share the entity’s invalidation watermark with every tracked variant.
Sourcepub fn budget(self, budget: SourceBudget) -> Self
pub fn budget(self, budget: SourceBudget) -> Self
The source deadline. Defaults to 60 s.
Sourcepub fn codec(self, codec: Arc<dyn Codec<T>>) -> Self
pub fn codec(self, codec: Arc<dyn Codec<T>>) -> Self
Replace the JSON codec; required by register_custom.
Sourcepub fn comparator(
self,
comparator: impl Fn(&T, &T) -> bool + Send + Sync + 'static,
) -> Self
pub fn comparator( self, comparator: impl Fn(&T, &T) -> bool + Send + Sync + 'static, ) -> Self
Application equality for shadow validation. Defaults to PartialEq.
Sourcepub fn should_recover(
self,
predicate: impl Fn(&Error) -> bool + Send + Sync + 'static,
) -> Self
pub fn should_recover( self, predicate: impl Fn(&Error) -> bool + Send + Sync + 'static, ) -> Self
Override the instance classifier for stale recovery.
Sourcepub fn preview(
self,
preview: impl Fn(&T) -> Option<String> + Send + Sync + 'static,
) -> Self
pub fn preview( self, preview: impl Fn(&T) -> Option<String> + Send + Sync + 'static, ) -> Self
The text mismatch warnings log for each value in place of its JSON;
required for value fields under
register_custom. Difference fields then
come only from mismatch_diff. See Preview.
Sourcepub fn mismatch_diff(
self,
hook: impl Fn(&T, &T) -> Vec<MismatchEntry> + Send + Sync + 'static,
) -> Self
pub fn mismatch_diff( self, hook: impl Fn(&T, &T) -> Vec<MismatchEntry> + Send + Sync + 'static, ) -> Self
Replace the built-in difference computation of mismatch warnings;
required for difference fields under
register_custom. See MismatchDiffHook.
Sourcepub fn key(self, key: impl Fn(&Args) -> KeySpec + Send + Sync + 'static) -> Self
pub fn key(self, key: impl Fn(&Args) -> KeySpec + Send + Sync + 'static) -> Self
Select every input dimension that affects the value. Runs only for enabled calls.
Sourcepub fn source<F, Fut>(self, source: F) -> Self
pub fn source<F, Fut>(self, source: F) -> Self
The source of truth. It receives the call’s scope so nested cached calls can participate; served-hit shadow validation invokes it again under disabled caching.
Sourcepub fn register_custom(self) -> Result<UseCase<Args, T>, ConfigError>
pub fn register_custom(self) -> Result<UseCase<Args, T>, ConfigError>
Register with an explicit codec and comparator (set with
codec and comparator).
Source§impl<Args, T> UseCaseBuilder<Args, T>
impl<Args, T> UseCaseBuilder<Args, T>
Sourcepub fn register(self) -> Result<UseCase<Args, T>, ConfigError>
pub fn register(self) -> Result<UseCase<Args, T>, ConfigError>
Register with the JSON codec and PartialEq comparison unless
overridden. Mismatch warnings use the values’ JSON, as for
Operation::new.