pub trait RuntimeData:
Send
+ Sync
+ 'static {
Show 21 methods
// 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 try_create_for<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
input: Row,
) -> RuntimeFuture<'a, Result<Row, ValidationError>> { ... }
fn find_by_key_for<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
key: &'a str,
) -> RuntimeFuture<'a, Option<Row>> { ... }
fn try_update_by_key_for<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
key: &'a str,
input: Row,
) -> RuntimeFuture<'a, Result<Row, ValidationError>> { ... }
fn delete_by_key_for<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
key: &'a str,
) -> RuntimeFuture<'a, u64> { ... }
fn try_update_for<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
id: i64,
input: Row,
) -> RuntimeFuture<'a, Result<Row, ValidationError>> { ... }
fn delete_for<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
id: i64,
) -> RuntimeFuture<'a, u64> { ... }
fn stats<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
) -> RuntimeFuture<'a, Vec<Stat>> { ... }
fn options_for<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
field: &'a str,
) -> RuntimeFuture<'a, Vec<(String, String)>> { ... }
fn options_with<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
field: &'a str,
state: &'a Row,
) -> RuntimeFuture<'a, Vec<(String, String)>> { ... }
fn tabs_for<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
) -> RuntimeFuture<'a, Option<Vec<Tab>>> { ... }
fn validate_form(
&self,
form: &FormInput,
operation: Operation,
) -> FieldErrors { ... }
}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§
Sourcefn list<'a>(
&'a self,
db: &'a Database,
query: &'a ListQuery,
) -> RuntimeFuture<'a, Page<Row>>
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. The rows and the total must meet the active tab’s
conditions in ListQuery::filter (see ListFilter); a
per_page of 0 asks only for the total, to count a tab’s rows.
Sourcefn find<'a>(
&'a self,
db: &'a Database,
id: i64,
) -> RuntimeFuture<'a, Option<Row>>
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.
Sourcefn create<'a>(&'a self, db: &'a Database, input: Row) -> RuntimeFuture<'a, Row>
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.
Sourcefn update<'a>(
&'a self,
db: &'a Database,
id: i64,
input: Row,
) -> RuntimeFuture<'a, Row>
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.
Provided Methods§
Sourcefn options<'a>(
&'a self,
db: &'a Database,
field: &'a str,
) -> RuntimeFuture<'a, Vec<(String, String)>>
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.
Sourcefn list_for<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
query: &'a ListQuery,
) -> RuntimeFuture<'a, Page<Row>>
fn list_for<'a>( &'a self, db: &'a Database, user: &'a ActingUser, query: &'a ListQuery, ) -> RuntimeFuture<'a, Page<Row>>
Sourcefn find_for<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
id: i64,
) -> RuntimeFuture<'a, Option<Row>>
fn find_for<'a>( &'a self, db: &'a Database, user: &'a ActingUser, id: i64, ) -> RuntimeFuture<'a, Option<Row>>
Sourcefn create_for<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
input: Row,
) -> RuntimeFuture<'a, Row>
fn create_for<'a>( &'a self, db: &'a Database, user: &'a ActingUser, input: Row, ) -> RuntimeFuture<'a, Row>
Sourcefn update_for<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
id: i64,
input: Row,
) -> RuntimeFuture<'a, Row>
fn update_for<'a>( &'a self, db: &'a Database, user: &'a ActingUser, id: i64, input: Row, ) -> RuntimeFuture<'a, Row>
Sourcefn try_create_for<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
input: Row,
) -> RuntimeFuture<'a, Result<Row, ValidationError>>
fn try_create_for<'a>( &'a self, db: &'a Database, user: &'a ActingUser, input: Row, ) -> RuntimeFuture<'a, Result<Row, ValidationError>>
create_for that may refuse the row with field messages, as
Laravel’s ValidationException::withMessages(): answer Ok(Err(ValidationError)) and
the panel shows the create form again with 422, each message under its field and the
typed values kept. The panel calls this method; the default is
create_for, which never refuses.
fn try_create_for<'a>(&'a self, db: &'a Database, user: &'a ActingUser, input: Row)
-> RuntimeFuture<'a, Result<Row, ValidationError>> {
Box::pin(async move {
if name_is_taken(db, &input).await? {
return Ok(Err(ValidationError::with_messages([("name", "That name is in use.")])));
}
Ok(Ok(save(db, input).await?))
})
}Sourcefn find_by_key_for<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
key: &'a str,
) -> RuntimeFuture<'a, Option<Row>>
fn find_by_key_for<'a>( &'a self, db: &'a Database, user: &'a ActingUser, key: &'a str, ) -> RuntimeFuture<'a, Option<Row>>
find_for by the record’s key in the URL, for a resource whose
records are addressed by a key other than the numeric id
(RuntimeResource::record_route_key_name, as Filament’s $recordRouteKeyName), such
as a post type’s key. The default parses key as an id and calls
find_for; a key that is not a whole number finds nothing.
Sourcefn try_update_by_key_for<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
key: &'a str,
input: Row,
) -> RuntimeFuture<'a, Result<Row, ValidationError>>
fn try_update_by_key_for<'a>( &'a self, db: &'a Database, user: &'a ActingUser, key: &'a str, input: Row, ) -> RuntimeFuture<'a, Result<Row, ValidationError>>
try_update_for by the record’s key, as
find_by_key_for. The default parses key as an id.
Sourcefn delete_by_key_for<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
key: &'a str,
) -> RuntimeFuture<'a, u64>
fn delete_by_key_for<'a>( &'a self, db: &'a Database, user: &'a ActingUser, key: &'a str, ) -> RuntimeFuture<'a, u64>
delete_for by the record’s key, as
find_by_key_for. The default parses key as an id; a key
that is not a whole number deletes nothing.
Sourcefn try_update_for<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
id: i64,
input: Row,
) -> RuntimeFuture<'a, Result<Row, ValidationError>>
fn try_update_for<'a>( &'a self, db: &'a Database, user: &'a ActingUser, id: i64, input: Row, ) -> RuntimeFuture<'a, Result<Row, ValidationError>>
update_for that may refuse the row with field messages, as
try_create_for for the edit form. The panel calls it only
after find_for found the row and the policy allowed the update. The
default is update_for, which never refuses.
Sourcefn delete_for<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
id: i64,
) -> RuntimeFuture<'a, u64>
fn delete_for<'a>( &'a self, db: &'a Database, user: &'a ActingUser, id: i64, ) -> RuntimeFuture<'a, u64>
Sourcefn stats<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
) -> RuntimeFuture<'a, Vec<Stat>>
fn stats<'a>( &'a self, db: &'a Database, user: &'a ActingUser, ) -> RuntimeFuture<'a, Vec<Stat>>
The dashboard cards of the resource for the signed-in user, as
IgniteResource::stats. The panel shows them only to a
user who may view the resource’s records. The default is none.
Sourcefn options_for<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
field: &'a str,
) -> RuntimeFuture<'a, Vec<(String, String)>>
fn options_for<'a>( &'a self, db: &'a Database, user: &'a ActingUser, field: &'a str, ) -> RuntimeFuture<'a, Vec<(String, String)>>
Sourcefn options_with<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
field: &'a str,
state: &'a Row,
) -> RuntimeFuture<'a, Vec<(String, String)>>
fn options_with<'a>( &'a self, db: &'a Database, user: &'a ActingUser, field: &'a str, state: &'a Row, ) -> RuntimeFuture<'a, Vec<(String, String)>>
The choices of the field at field for the form’s current values, as Filament’s
dependent select, options(fn (Get $get) => ...) on a field whose controlling field is
live(): such as a location rule’s values, which depend on the rule’s parameter. The
panel calls it each time it shows the form, again when a live field changes (see
FieldConditions::live), and when it checks a submitted value, so a choice the
current values leave out cannot be saved.
field is the field’s path of names, without row numbers: "city" for a field of the
form, "rules.value" for the sub-field value of each row of the repeater rules,
"content.hero.style" for a sub-field of a flexible content block. state holds the
current values around the field, as Filament’s $get reads its siblings: the form’s
fields for a field of the form (a structured field’s value as JSON), and the row’s (or
group’s) values for a sub-field. A blank value is missing or null. The default is
options_for, which does not depend on the values.
A value no longer among the choices after the controlling field changed shows as not
chosen, and is refused if saved, which is Filament’s afterStateUpdated reset of the
dependent field, done by the server.
Sourcefn tabs_for<'a>(
&'a self,
db: &'a Database,
user: &'a ActingUser,
) -> RuntimeFuture<'a, Option<Vec<Tab>>>
fn tabs_for<'a>( &'a self, db: &'a Database, user: &'a ActingUser, ) -> RuntimeFuture<'a, Option<Vec<Tab>>>
The tabs of the list page for the signed-in user, computed on each list request, as
Filament’s getTabs() is a method of the List page: such as one tab per role on a users
list, which changes when a role is added. None, the default, keeps the resource’s
tabs. The tab query parameter, the default tab and the
counts work as for the declared tabs.
Sourcefn validate_form(&self, form: &FormInput, operation: Operation) -> FieldErrors
fn validate_form(&self, form: &FormInput, operation: Operation) -> FieldErrors
Rules on the submitted form, checked beside the fields’ own checks before the row is
built, as the rules of a Laravel form request: such as a password’s minimum length,
which the row cannot show because a password is hashed in it. operation is
Operation::Create or Operation::Edit. Each error is keyed by the field’s name and
shows under it, with 422, as a field’s own error. The default is none.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".