1use crate::query::QueryBuilder;
2
3pub struct Scope<T> {
10 pub(crate) apply_fn: Box<dyn FnOnce(QueryBuilder<T>) -> QueryBuilder<T> + Send>,
11}
12
13impl<T: Send + Sync + Unpin + 'static> Scope<T> {
14 pub fn new<F>(f: F) -> Self
15 where
16 F: FnOnce(QueryBuilder<T>) -> QueryBuilder<T> + Send + 'static,
17 {
18 Self {
19 apply_fn: Box::new(f),
20 }
21 }
22
23 pub fn none() -> Self {
25 Self::new(|q| q)
26 }
27}
28
29pub trait ModelScopes: Sized + Send + Sync + Unpin + 'static {
32 fn scope(s: Scope<Self>) -> crate::query::QueryBuilder<Self>;
33}