pub trait OptionSource:
Sized
+ Send
+ Sync
+ 'static {
type Model: Model + IntoExpr<Self::Model> + Send + Sync + 'static;
// Required method
fn scoped_query(cx: &Cx) -> Result<Query<List<Self::Model>>>;
// Provided methods
fn allows(_cx: &Cx, _ability: Ability<'_, Self::Model>) -> bool { ... }
fn requires_tenant(_cx: &Cx) -> bool { ... }
fn search_expr(_cx: &Cx, _term: &str) -> Option<Expr<bool>> { ... }
fn order_by(_cx: &Cx) -> Option<OrderByExpr> { ... }
}Expand description
Describes the source a relationship option loader reads.
Every Resource is one, answering from its def as the request’s panel
mounted it.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn allows(_cx: &Cx, _ability: Ability<'_, Self::Model>) -> bool
fn allows(_cx: &Cx, _ability: Ability<'_, Self::Model>) -> bool
Whether the current user may see the rows ability names; refusing ViewAny fails the
whole load closed. Defaults to refusing everything.
Sourcefn requires_tenant(_cx: &Cx) -> bool
fn requires_tenant(_cx: &Cx) -> bool
Declares whether the source’s rows are tenant-owned and fails a tenantless request closed.
Sourcefn search_expr(_cx: &Cx, _term: &str) -> Option<Expr<bool>>
fn search_expr(_cx: &Cx, _term: &str) -> Option<Expr<bool>>
States the related source’s search predicate for term, or None when it declares no
searchable column.
Sourcefn order_by(_cx: &Cx) -> Option<OrderByExpr>
fn order_by(_cx: &Cx) -> Option<OrderByExpr>
States the related source’s declared default ordering.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
Source§impl<R: Resource> OptionSource for R
Every Resource is an OptionSource, answering from its def
as the request’s panel mounted it.
impl<R: Resource> OptionSource for R
Every Resource is an OptionSource, answering from its def
as the request’s panel mounted it.
scoped_query forwards to
scoped_query, so an option load inherits the tenant gate and filter
exactly as every other loader does. The search expression and default ordering come from the
resource’s table, which is where “the option search searches the
related resource’s searchable columns” lives.