Skip to main content

ResourceClient

Struct ResourceClient 

Source
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>

Source

pub fn url(&self) -> String

R’s list URL, e.g. /admin/posts.

§Panics

When the panel does not mount R.

Source

pub async fn list(&self) -> Reply<'c, 'a, FieldOf<R>>

The list page.

Source

pub async fn list_with(&self, query: &str) -> Reply<'c, 'a, FieldOf<R>>

The list page with query, e.g. "search=ada&page=2".

Source

pub async fn create_page(&self) -> Reply<'c, 'a, FieldOf<R>>

The create page.

§Panics

When R serves no create page.

Source

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.

Source

pub async fn view(&self, record: &R::Model) -> Reply<'c, 'a, FieldOf<R>>

record’s detail page.

§Panics

When R declares no detail page, or its rows have no route.

Source

pub async fn edit_page(&self, record: &R::Model) -> Reply<'c, 'a, FieldOf<R>>

record’s edit page.

§Panics

When R has no record form, or its rows have no route.

Source

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.

Source

pub fn delete(&self, record: &R::Model) -> Submission<'c, 'a, Infallible>

A confirmed delete of record, as the delete dialog posts it.

§Panics

When R’s rows have no route.

Source

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.

Source

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.

Source

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.

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> Forget for ResourceClient<'c, 'a, R>

§

impl<'c, 'a, R> Freeze for ResourceClient<'c, 'a, R>
where PhantomData<fn() -> R>: Freeze,

§

impl<'c, 'a, R> Move for ResourceClient<'c, 'a, R>

§

impl<'c, 'a, R> Send for ResourceClient<'c, 'a, R>
where PhantomData<fn() -> R>: Send,

§

impl<'c, 'a, R> Sync for ResourceClient<'c, 'a, R>
where PhantomData<fn() -> R>: Sync,

§

impl<'c, 'a, R> Unpin for ResourceClient<'c, 'a, R>
where PhantomData<fn() -> R>: Unpin,

§

impl<'c, 'a, R> UnsafeUnpin for ResourceClient<'c, 'a, R>
where PhantomData<fn() -> R>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more