pub struct ResourceClient<'c, 'a, R> { /* private fields */ }Expand description
Requests to R in the panel TestClient::panel names, built by
TestClient::resource.
let posts = client.resource::<PostResource>();
let reply = posts
.create()
.set(PostFormField::Title, "Hello")
.submit()
.await;
assert_eq!(reply.status(), 303);
assert_eq!(reply.follow().await.rows().len(), 1);Implementations§
Source§impl<'c, 'a, R: Resource> ResourceClient<'c, 'a, R>
impl<'c, 'a, R: Resource> ResourceClient<'c, 'a, R>
Sourcepub async fn list_with(&self, query: &str) -> Reply<'c, 'a, FieldOf<R>>
pub async fn list_with(&self, query: &str) -> Reply<'c, 'a, FieldOf<R>>
The list page with query, e.g. "search=ada&page=2".
Sourcepub async fn create_page(&self) -> Reply<'c, 'a, FieldOf<R>>
pub async fn create_page(&self) -> Reply<'c, 'a, FieldOf<R>>
Sourcepub fn create(&self) -> Submission<'c, 'a, FieldOf<R>>
pub fn create(&self) -> Submission<'c, 'a, FieldOf<R>>
A submission of the create form, posting only the fields Submission::set names.
§Panics
When R serves no create page.
Sourcepub fn edit(&self, record: &R::Model) -> Submission<'c, 'a, FieldOf<R>>
pub fn edit(&self, record: &R::Model) -> Submission<'c, 'a, FieldOf<R>>
A submission of record’s edit form. It posts only the fields Submission::set names,
and the edit leaves every other field as stored.
§Panics
When R has no record form, or its rows have no route.
Sourcepub fn delete(&self, record: &R::Model) -> Submission<'c, 'a, Infallible>
pub fn delete(&self, record: &R::Model) -> Submission<'c, 'a, Infallible>
Sourcepub fn action<A: Action<R>>(
&self,
record: &R::Model,
) -> Submission<'c, 'a, Infallible>
pub fn action<A: Action<R>>( &self, record: &R::Model, ) -> Submission<'c, 'a, Infallible>
A confirmed run of the action A on record. An input the action asks for goes in with
Submission::set_key.
§Panics
When R does not declare A on a record.
Sourcepub fn bulk_action<A: Action<R>>(
&self,
keys: impl IntoIterator<Item = impl AsRef<str>>,
) -> Submission<'c, 'a, Infallible>
pub fn bulk_action<A: Action<R>>( &self, keys: impl IntoIterator<Item = impl AsRef<str>>, ) -> Submission<'c, 'a, Infallible>
A confirmed run of the bulk action A on the rows keyed keys, as Reply::row_keys
reads them.
§Panics
When R does not declare A in its bulk bar.
Sourcepub fn bulk_action_matching<A: Action<R>>(
&self,
query: &str,
) -> Submission<'c, 'a, Infallible>
pub fn bulk_action_matching<A: Action<R>>( &self, query: &str, ) -> Submission<'c, 'a, Infallible>
A confirmed run of the bulk action A on every record the list’s query selects, as the
bulk bar’s Select all matching posts it: query spells the list’s URL query, without the
leading ?, such as f.status=draft.
§Panics
When R does not declare A in its bulk bar.