pub struct Arg(/* private fields */);Expand description
Matcher for one argument in with_args.
Plain values and Any are usually enough; build an Arg with
Arg::matching for a custom check.
Implementations§
Source§impl Arg
impl Arg
Sourcepub fn matching(
predicate: impl Fn(&Value) -> bool + Send + Sync + 'static,
) -> Self
pub fn matching( predicate: impl Fn(&Value) -> bool + Send + Sync + 'static, ) -> Self
Accept an argument for which predicate returns true.
For arguments that cannot be compared exactly, but still have properties worth checking: a range, a format, or several acceptable values.
use sea_orm::{DbBackend, EntityTrait, Value};
use leadline::{Arg, MockDb};
let mock = MockDb::new(DbBackend::Postgres);
let positive = Arg::matching(|value| matches!(value, Value::Int(Some(id)) if *id > 0));
mock.expect_delete::<cake::Entity>().with_args((positive,)).rows_affected(1);
let db = mock.connection().await;
cake::Entity::delete_by_id(12).exec(&db).await.unwrap();Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Arg
impl !UnwindSafe for Arg
impl Freeze for Arg
impl Send for Arg
impl Sync for Arg
impl Unpin for Arg
impl UnsafeUnpin for Arg
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more