Skip to main content

OptionSource

Trait OptionSource 

Source
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§

Source

type Model: Model + IntoExpr<Self::Model> + Send + Sync + 'static

The model whose rows become options.

Required Methods§

Source

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.

Provided Methods§

Source

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.

Source

fn requires_tenant(_cx: &Cx) -> bool

Declares whether the source’s rows are tenant-owned and fails a tenantless request closed.

Source

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.

Source

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.

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.