Trait Idempotence

Source
pub trait Idempotence {
    type Idempotent;

    // Required method
    fn idempotent(self) -> Self::Idempotent;
}
Expand description

The Idempotence trait is implemented for types that have an idempotent “version”.

Idempotent in the context of flawless means side effect free. This trait offers a way to model a contract between library creators and users that certain APIs can be invoked multiple times. For example, an HTTP client can have two versions, one that performs requests to endpoints that have side effects and another that performs requests to idempotent endpoints. It’s still up to the user to pick the idempotent version, because they are the only one that actually knows if their endpoint is idempotent or not. In case the call is interrupted mid-execution and flawless can’t tell if the endpoint observed the call, it will only retry it in case the idempotent version was used. Otherwise, it will fail the workflow and require the user to use their domain expertise and resolve the issue manually.

The trait has one method idempotent, that returns a version of the type exposing only a side effect free API.

Required Associated Types§

Required Methods§

Source

fn idempotent(self) -> Self::Idempotent

Implementors§