pub trait Filter:
Send
+ Sync
+ 'static {
// Required method
fn check(&self, ctx: &Context) -> bool;
}Expand description
A predicate evaluated against an incoming Context.
Filters are Send + Sync + 'static and cheap to clone, making them safe
to share across tasks. Combine filters with FilterExt::and,
FilterExt::or, and FilterExt::not.
Implement this trait to create custom filters:
ⓘ
use rustigram_bot::filter::Filter;
use rustigram_bot::Context;
#[derive(Clone)]
struct HasPhotoFilter;
impl Filter for HasPhotoFilter {
fn check(&self, ctx: &Context) -> bool {
ctx.message().and_then(|m| m.photo.as_ref()).is_some()
}
}Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".