#[non_exhaustive]pub enum CallbackPattern {
Data(Regex),
Game(Regex),
Both {
data: Regex,
game: Regex,
},
Predicate(Arc<dyn Fn(&str) -> bool + Send + Sync>),
}Expand description
Pattern to match against callback query data or game short name.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Data(Regex)
Match callback_query.data against this compiled regex.
Game(Regex)
Match callback_query.game_short_name against this compiled regex.
Both
Match both: data against the first regex, game against the second.
Fields
Predicate(Arc<dyn Fn(&str) -> bool + Send + Sync>)
Match callback_query.data using an arbitrary predicate function.
This covers Python’s callable(data) and isinstance(data, type)
patterns in a Rust-idiomatic way. The predicate receives the data
string and returns true if the callback query should be handled.
Trait Implementations§
Source§impl Clone for CallbackPattern
impl Clone for CallbackPattern
Source§fn clone(&self) -> CallbackPattern
fn clone(&self) -> CallbackPattern
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CallbackPattern
impl !RefUnwindSafe for CallbackPattern
impl Send for CallbackPattern
impl Sync for CallbackPattern
impl Unpin for CallbackPattern
impl UnsafeUnpin for CallbackPattern
impl !UnwindSafe for CallbackPattern
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