Skip to main content

UseCaseBuilder

Struct UseCaseBuilder 

Source
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>
where Args: Clone + Send + Sync + 'static, T: Send + Sync + 'static,

Source

pub fn policy(self, policy: Policy) -> Self

Static policy captured for every call of this use case.

Source

pub fn tracked(self, tracked: bool) -> Self

Share the entity’s invalidation watermark with every tracked variant.

Source

pub fn budget(self, budget: SourceBudget) -> Self

The source deadline. Defaults to 60 s.

Source

pub fn codec(self, codec: Arc<dyn Codec<T>>) -> Self

Replace the JSON codec; required by register_custom.

Source

pub fn comparator( self, comparator: impl Fn(&T, &T) -> bool + Send + Sync + 'static, ) -> Self

Application equality for shadow validation. Defaults to PartialEq.

Source

pub fn should_recover( self, predicate: impl Fn(&Error) -> bool + Send + Sync + 'static, ) -> Self

Override the instance classifier for stale recovery.

Source

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.

Source

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.

Source

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.

Source

pub fn source<F, Fut>(self, source: F) -> Self
where F: Fn(Scope, Args) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<T, BoxError>> + Send + 'static,

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.

Source

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>
where Args: Clone + Send + Sync + 'static, T: Serialize + DeserializeOwned + PartialEq + Send + Sync + 'static,

Source

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.

Trait Implementations§

Source§

impl<Args, T> Debug for UseCaseBuilder<Args, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Args, T> !RefUnwindSafe for UseCaseBuilder<Args, T>

§

impl<Args, T> !UnwindSafe for UseCaseBuilder<Args, T>

§

impl<Args, T> Freeze for UseCaseBuilder<Args, T>

§

impl<Args, T> Send for UseCaseBuilder<Args, T>

§

impl<Args, T> Sync for UseCaseBuilder<Args, T>

§

impl<Args, T> Unpin for UseCaseBuilder<Args, T>

§

impl<Args, T> UnsafeUnpin for UseCaseBuilder<Args, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.