Skip to main content

AsyncSpecification

Trait AsyncSpecification 

Source
pub trait AsyncSpecification<T: ?Sized + Sync>: Sync {
    type Error: Send;

    // Required method
    fn is_satisfied_by<'candidate>(
        &'candidate self,
        candidate: &'candidate T,
    ) -> impl Future<Output = Result<bool, Self::Error>> + Send + 'candidate;

    // Provided methods
    fn and<Other>(self, other: Other) -> AsyncAnd<Self, Other>
       where Self: Sized,
             Other: AsyncSpecification<T, Error = Self::Error> { ... }
    fn or<Other>(self, other: Other) -> AsyncOr<Self, Other>
       where Self: Sized,
             Other: AsyncSpecification<T, Error = Self::Error> { ... }
    fn not(self) -> AsyncNot<Self>
       where Self: Sized { ... }
}
Expand description

A runtime-neutral asynchronous rule over a borrowed, Sync candidate.

The returned future is Send, so callers may hand it to an executor that moves work between threads. This trait uses return-position impl Future and is therefore not directly dyn-compatible; use BoxedAsyncSpecification when object-safe dynamic dispatch is required. No executor or async runtime is selected by this API.

ⓘ
use specification_core::AsyncSpecification;

fn accepts_dynamic(_: &dyn AsyncSpecification<i32, Error = &'static str>) {}

Required Associated Types§

Source

type Error: Send

The typed error produced by asynchronous evaluation.

Required Methods§

Source

fn is_satisfied_by<'candidate>( &'candidate self, candidate: &'candidate T, ) -> impl Future<Output = Result<bool, Self::Error>> + Send + 'candidate

Evaluates the rule and returns a Send future with a typed result.

Provided Methods§

Source

fn and<Other>(self, other: Other) -> AsyncAnd<Self, Other>
where Self: Sized, Other: AsyncSpecification<T, Error = Self::Error>,

Combines this rule with other using asynchronous short-circuiting AND.

Source

fn or<Other>(self, other: Other) -> AsyncOr<Self, Other>
where Self: Sized, Other: AsyncSpecification<T, Error = Self::Error>,

Combines this rule with other using asynchronous short-circuiting OR.

Source

fn not(self) -> AsyncNot<Self>
where Self: Sized,

Creates an asynchronous rule that negates this rule’s result.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T: ?Sized + Sync, Error: Send> AsyncSpecification<T> for BoxedAsyncSpecification<T, Error>

Source§

type Error = Error

Source§

impl<T: ?Sized + Sync, Inner> AsyncSpecification<T> for AsyncNot<Inner>
where Inner: AsyncSpecification<T>,

Source§

type Error = <Inner as AsyncSpecification<T>>::Error

Source§

impl<T: ?Sized + Sync, Left, Right> AsyncSpecification<T> for AsyncAnd<Left, Right>
where Left: AsyncSpecification<T>, Right: AsyncSpecification<T, Error = Left::Error>,

Source§

impl<T: ?Sized + Sync, Left, Right> AsyncSpecification<T> for AsyncOr<Left, Right>
where Left: AsyncSpecification<T>, Right: AsyncSpecification<T, Error = Left::Error>,