pub struct RequestHandler { /* private fields */ }

Implementations

Creates a new RequestHandler instance using an api_key obtained from Hypixel.

RequestHandler::request can be used to queue as many requests as required for execution without ever going over the limit set by Hypixel’s API. This limit is derived automatically and thus can be completely avoided by user code.

Examples
use hypixel_api::RequestHandler;

let api_key = Uuid::from_str(env!("HYPIXEL_API_KEY")).unwrap();
let request_handler = RequestHandler::new(api_key);

// Send requests ...

Queues a new request for execution and returns a JoinHandle to it.

Arguments

path should be a relative path to the API (without leading /), such as "key" or "status?uuid=...". See the API.

If authenticated is true then the API key will be sent along as a header.

Errors

If any part of the execution process fails, a HypixelApiError will be returned.

Examples
use hypixel_api::RequestHandler;

let api_key = Uuid::from_str(env!("HYPIXEL_API_KEY")).unwrap();
let request_handler = RequestHandler::new(api_key);
let request1 = request_handler.request::<StatusReply>("status?uuid=069a79f4-44e9-4726-a5be-fca90e38aaf5", true);

// send more requests ...

let reply: StatusReply = request1.await.unwrap().unwrap();
// use reply ...

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

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

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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

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