Struct rosu_v2::OsuBuilder
source · pub struct OsuBuilder { /* private fields */ }
Expand description
Builder struct for an Osu
client.
client_id
as well as client_secret
must be specified before building.
For more info, check out https://osu.ppy.sh/docs/index.html#client-credentials-grant
Implementations§
source§impl OsuBuilder
impl OsuBuilder
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new OsuBuilder
sourcepub async fn build(self) -> OsuResult<Osu>
pub async fn build(self) -> OsuResult<Osu>
Build an Osu
client.
To build the client, the client id and secret are being used to acquire a token from the API which expires after a certain time. The client will from then on update the token regularly on its own.
Errors
Returns an error if
- client id was not set
- client secret was not set
- API did not provide a token for the given client id and client secret
sourcepub fn client_id(self, client_id: u64) -> Self
pub fn client_id(self, client_id: u64) -> Self
Set the client id of the application.
For more info, check out https://osu.ppy.sh/docs/index.html#client-credentials-grant
sourcepub fn client_secret(self, client_secret: impl Into<String>) -> Self
pub fn client_secret(self, client_secret: impl Into<String>) -> Self
Set the client secret of the application.
For more info, check out https://osu.ppy.sh/docs/index.html#client-credentials-grant
After acquiring the authorization code from a user through OAuth, use this method to provide the given code, and specified redirect uri.
For more info, check out https://osu.ppy.sh/docs/index.html#authorization-code-grant
sourcepub fn retries(self, retries: usize) -> Self
pub fn retries(self, retries: usize) -> Self
In case the request times out, retry up to this many times, defaults to 2.
sourcepub fn timeout(self, duration: Duration) -> Self
pub fn timeout(self, duration: Duration) -> Self
Set the timeout for requests, defaults to 10 seconds.
sourcepub fn ratelimit(self, reqs_per_sec: u32) -> Self
pub fn ratelimit(self, reqs_per_sec: u32) -> Self
Set the amount of requests that can be made in one second, defaults to 15. The given value will be clamped between 1 and 20.
Check out the osu!api’s terms of use for acceptable values.