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.
Auto Trait Implementations§
impl<'c, 'a, R> !RefUnwindSafe for ResourceClient<'c, 'a, R>
impl<'c, 'a, R> !UnwindSafe for ResourceClient<'c, 'a, R>
impl<'c, 'a, R> Freeze for ResourceClient<'c, 'a, R>
impl<'c, 'a, R> Send for ResourceClient<'c, 'a, R>
impl<'c, 'a, R> Sync for ResourceClient<'c, 'a, R>
impl<'c, 'a, R> Unpin for ResourceClient<'c, 'a, R>
impl<'c, 'a, R> UnsafeUnpin for ResourceClient<'c, 'a, R>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more