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§
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.
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 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 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)>>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".