pub trait OptionSource:
Sized
+ Send
+ Sync
+ 'static {
type Model: Model + IntoExpr<Self::Model> + Send + Sync + 'static;
// Required methods
fn scoped_query(cx: &Cx) -> Result<Query<List<Self::Model>>>;
fn label(cx: &Cx, record: &Self::Model) -> String;
// 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 context’s panel
mounted it.
Required Associated Types§
Required Methods§
Sourcefn scoped_query(cx: &Cx) -> Result<Query<List<Self::Model>>>
fn scoped_query(cx: &Cx) -> Result<Query<List<Self::Model>>>
States the tenant-scoped seed query every option load starts from and reports an unscopable source as misdeclared.
Sourcefn label(cx: &Cx, record: &Self::Model) -> String
fn label(cx: &Cx, record: &Self::Model) -> String
Labels record wherever a relationship choice offers it or a
RelationColumn::of shows it.
A Resource answers with its def’s
record_title, else its label and the record’s key.
The record is loaded without its relations.
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.
A Resource answers from its def’s
tenancy. An implementor that is not one declares no def and
no tenant lens the framework could read, so it states the boolean and scopes
scoped_query itself.
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 context’s panel mounted it.
impl<R: Resource> OptionSource for R
Every Resource is an OptionSource, answering from its def
as the context’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, whose searchable columns the option search searches
with the record_title column, and each record’s label is its
title.