pub struct ApiClient { /* private fields */ }
Implementations
sourceimpl Client
impl Client
sourcepub fn builder(api_url: &str) -> Builder
pub fn builder(api_url: &str) -> Builder
Get a Builder
instance to further customize the API Client
.
The API URL should be the absolute path to api.php.
sourcepub async fn new(api_url: &'_ str) -> Result<Client, Error>
pub async fn new(api_url: &'_ str) -> Result<Client, Error>
Get an API Client
instance. The API URL should be the absolute
path to api.php.
sourcepub async fn get_value<P>(&'_ self, params: P) -> Result<Value, Error> where
P: Into<Params>,
pub async fn get_value<P>(&'_ self, params: P) -> Result<Value, Error> where
P: Into<Params>,
Same as get()
, but return a serde_json::Value
sourcepub async fn get<P, T>(&'_ self, params: P) -> Result<T, Error> where
P: Into<Params>,
T: DeserializeOwned,
pub async fn get<P, T>(&'_ self, params: P) -> Result<T, Error> where
P: Into<Params>,
T: DeserializeOwned,
Make an arbitrary API request using HTTP GET.
sourcepub async fn query_response<T, U, P>(&'_ self, extra: P) -> Result<T, Error> where
T: ApiResponse<U> + DeserializeOwned,
P: Into<Params>,
pub async fn query_response<T, U, P>(&'_ self, extra: P) -> Result<T, Error> where
T: ApiResponse<U> + DeserializeOwned,
P: Into<Params>,
Easily execute a request based on a mwapi_responses
-generated struct.
Any extra custom parameters can be passed in to the function and were merged with the default request parameters.
sourcepub async fn post_with_token<P, T>(
&'_ self,
token_type: &'_ str,
params: P
) -> Result<T, Error> where
P: Into<Params>,
T: DeserializeOwned,
pub async fn post_with_token<P, T>(
&'_ self,
token_type: &'_ str,
params: P
) -> Result<T, Error> where
P: Into<Params>,
T: DeserializeOwned,
Make an API POST request with a CSRF token. The correct token will automatically be fetched, and in case of a bad token error (if it expired), a new one will automatically be fetched and the request retried.
sourcepub async fn post<P, T>(&'_ self, params: P) -> Result<T, Error> where
P: Into<Params>,
T: DeserializeOwned,
pub async fn post<P, T>(&'_ self, params: P) -> Result<T, Error> where
P: Into<Params>,
T: DeserializeOwned,
Make an API POST request
sourcepub async fn post_value<P>(&'_ self, params: P) -> Result<Value, Error> where
P: Into<Params>,
pub async fn post_value<P>(&'_ self, params: P) -> Result<Value, Error> where
P: Into<Params>,
Same as post()
, but return a serde_json::Value
sourcepub fn http_client(&self) -> &Client
pub fn http_client(&self) -> &Client
Get access to the underlying reqwest::Client
to make arbitrary
GET/POST requests, sharing the connection pool and cookie storage.
For example, if you wanted to download images from the wiki.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more