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 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
pub fn set_http_client<P>(self, provider: P) -> Selfwhere
P: Into<HttpClientProvider>,
pub fn set_assert(self, assert: Assert) -> Self
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl !RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl !UnwindSafe for Builder
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)