Skip to main content

RuntimeData

Trait RuntimeData 

Source
pub trait RuntimeData:
    Send
    + Sync
    + 'static {
    // Required methods
    fn list<'a>(
        &'a self,
        db: &'a Database,
        query: &'a ListQuery,
    ) -> RuntimeFuture<'a, Page<Row>>;
    fn find<'a>(
        &'a self,
        db: &'a Database,
        id: i64,
    ) -> RuntimeFuture<'a, Option<Row>>;
    fn create<'a>(
        &'a self,
        db: &'a Database,
        input: Row,
    ) -> RuntimeFuture<'a, Row>;
    fn update<'a>(
        &'a self,
        db: &'a Database,
        id: i64,
        input: Row,
    ) -> RuntimeFuture<'a, Row>;
    fn delete<'a>(&'a self, db: &'a Database, id: i64) -> RuntimeFuture<'a, u64>;

    // Provided methods
    fn options<'a>(
        &'a self,
        db: &'a Database,
        field: &'a str,
    ) -> RuntimeFuture<'a, Vec<(String, String)>> { ... }
    fn list_for<'a>(
        &'a self,
        db: &'a Database,
        user: &'a ActingUser,
        query: &'a ListQuery,
    ) -> RuntimeFuture<'a, Page<Row>> { ... }
    fn find_for<'a>(
        &'a self,
        db: &'a Database,
        user: &'a ActingUser,
        id: i64,
    ) -> RuntimeFuture<'a, Option<Row>> { ... }
    fn create_for<'a>(
        &'a self,
        db: &'a Database,
        user: &'a ActingUser,
        input: Row,
    ) -> RuntimeFuture<'a, Row> { ... }
    fn update_for<'a>(
        &'a self,
        db: &'a Database,
        user: &'a ActingUser,
        id: i64,
        input: Row,
    ) -> RuntimeFuture<'a, Row> { ... }
    fn delete_for<'a>(
        &'a self,
        db: &'a Database,
        user: &'a ActingUser,
        id: i64,
    ) -> RuntimeFuture<'a, u64> { ... }
    fn options_for<'a>(
        &'a self,
        db: &'a Database,
        user: &'a ActingUser,
        field: &'a str,
    ) -> RuntimeFuture<'a, Vec<(String, String)>> { ... }
}
Expand description

Where the rows of a runtime resource live. The app implements it, so Ignite assumes no table layout: a custom post type can keep its rows in a shared posts table and its values in a meta table.

The methods mirror the queries of IgniteResource, with Rows for records and for validated input. The panel calls the *_for methods, which are given the signed-in ActingUser; by default each calls its method without the user, so a source that does not depend on the user implements only those.

Required Methods§

Source

fn list<'a>( &'a self, db: &'a Database, query: &'a ListQuery, ) -> RuntimeFuture<'a, Page<Row>>

Returns one page of rows that match query. The sort key, when there is one, is a sortable column of the resource.

Source

fn find<'a>( &'a self, db: &'a Database, id: i64, ) -> RuntimeFuture<'a, Option<Row>>

Returns the row with id, or None if there is no such row.

Source

fn create<'a>(&'a self, db: &'a Database, input: Row) -> RuntimeFuture<'a, Row>

Inserts a row from the validated input and returns it. See RegisteredResource::validate for the values input holds.

An Error::UniqueViolation whose index is named {slug}_{field}_unique shows on the form as "<label> is already taken.", as for a static resource. Any other error is a server error. A source whose indexes are named otherwise (or that keeps values in a meta table without such an index) should return a violation with an index of that name, or check the value before it writes.

Source

fn update<'a>( &'a self, db: &'a Database, id: i64, input: Row, ) -> RuntimeFuture<'a, Row>

Updates the row with id from the validated input and returns it. A key that is missing from input, such as a password left blank or a field the form did not send, keeps its stored value. A key whose value is null is an optional field the user cleared: store NULL, so the value is cleared, as a static resource does. A unique violation is reported as for create.

Source

fn delete<'a>(&'a self, db: &'a Database, id: i64) -> RuntimeFuture<'a, u64>

Deletes the row with id and returns the number of rows deleted.

Provided Methods§

Source

fn options<'a>( &'a self, db: &'a Database, field: &'a str, ) -> RuntimeFuture<'a, Vec<(String, String)>>

The choices of the field field, as (value, label) pairs in display order, for a field whose kind loads its options: a lookup, post object, relationship, taxonomy or user field. The default is no choices.

Source

fn list_for<'a>( &'a self, db: &'a Database, user: &'a ActingUser, query: &'a ListQuery, ) -> RuntimeFuture<'a, Page<Row>>

list for the signed-in user: the panel’s list calls it. Restrict the rows to the user here, as a Filament resource does in getEloquentQuery(), such as an author who sees only their own posts. The total counts the same rows. The default is list, for every user.

Source

fn find_for<'a>( &'a self, db: &'a Database, user: &'a ActingUser, id: i64, ) -> RuntimeFuture<'a, Option<Row>>

find for the signed-in user: the panel finds the record of the edit form, of its save and of the delete action with it. Return None for a row the user’s list leaves out, so the panel answers 404, as Filament resolves a record through getEloquentQuery(). The default is find, for every user.

Source

fn create_for<'a>( &'a self, db: &'a Database, user: &'a ActingUser, input: Row, ) -> RuntimeFuture<'a, Row>

create for the signed-in user, such as to make them the author. The default is create.

Source

fn update_for<'a>( &'a self, db: &'a Database, user: &'a ActingUser, id: i64, input: Row, ) -> RuntimeFuture<'a, Row>

update for the signed-in user, such as to keep a status the user may not set. The panel calls it only after find_for found the row and the Policy allowed the update. The default is update.

Source

fn delete_for<'a>( &'a self, db: &'a Database, user: &'a ActingUser, id: i64, ) -> RuntimeFuture<'a, u64>

delete for the signed-in user. The panel calls it only after find_for found the row and the Policy allowed the delete. The default is delete.

Source

fn options_for<'a>( &'a self, db: &'a Database, user: &'a ActingUser, field: &'a str, ) -> RuntimeFuture<'a, Vec<(String, String)>>

options for the signed-in user: the panel fills the form’s selects with these choices and checks a submitted value against them, so a choice left out cannot be saved, as a Filament select whose options depend on the user. The default is options.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§