pub struct Builder { /* private fields */ }Expand description
Build a new API client.
let client: Client = Client::builder("https://example.org/w/api.php")
.set_oauth2_token("foobar")
.set_errorformat(mwapi::ErrorFormat::Html)
.build().await?;Implementations§
Source§impl Builder
impl Builder
Sourcepub fn new(api_url: &str) -> Self
pub fn new(api_url: &str) -> Self
Create a new Builder instance. Typically you will use
Client::builder() instead.
Sourcepub fn from_client_with_url(client: &Client, api_url: &str) -> Self
pub fn from_client_with_url(client: &Client, api_url: &str) -> Self
Creates a new Builder instance based on an existing client,
replacing API URL with a new one.
The HTTP client will be cloned in order to reuse connection pools and improve speed.
Only some options are copied from the original client. Concurrency and bot passwords are not copied while OAuth token is copied.
Sourcepub fn set_user_agent(self, user_agent: &str) -> Self
pub fn set_user_agent(self, user_agent: &str) -> Self
Set a custom User-agent. Ideally follow the Wikimedia User-agent policy.
Sourcepub fn set_oauth2_token(self, oauth2_token: &str) -> Self
pub fn set_oauth2_token(self, oauth2_token: &str) -> Self
Set an OAuth2 token for authentication
Sourcepub fn set_errorformat(self, errorformat: ErrorFormat) -> Self
pub fn set_errorformat(self, errorformat: ErrorFormat) -> Self
Set the format error messages from the API should be in
Sourcepub fn set_concurrency(self, concurrency: usize) -> Self
pub fn set_concurrency(self, concurrency: usize) -> Self
Set how many requests should be processed in parallel. On Wikimedia wikis, you shouldn’t exceed the default of 1 without getting permission from a sysadmin.
Sourcepub fn set_maxlag(self, maxlag: u32) -> Self
pub fn set_maxlag(self, maxlag: u32) -> Self
Pause when the servers are lagged for how many seconds? Typically bots should set this to 5, while interactive usage should be much higher.
See mediawiki.org for more details.
pub fn set_retry_limit(self, limit: u32) -> Self
pub fn set_botpassword(self, username: &str, password: &str) -> Self
Sourcepub fn set_http_client<P>(self, provider: P) -> Selfwhere
P: Into<HttpClientProvider>,
pub fn set_http_client<P>(self, provider: P) -> Selfwhere
P: Into<HttpClientProvider>,
Sets an HttpClientProvider which creates ClientBuilder for the inner HTTP client.