pub struct EsiBuilder { /* private fields */ }Expand description
Builder for the Esi struct.
§Example
let mut esi = EsiBuilder::new()
.user_agent("some user agent")
.client_id("your_client_id")
.client_secret("your_client_secret")
.callback_url("your_callback_url")
.build()
.unwrap();§Overriding the API specification
If you will be creating multiple struct instances, you will probably run into the issue of needing to retrieve the API spec on each. Given that this operation is fairly expensive (certainly as far as the rest of the API endpoints that EVE makes available), this builder supports setting that struct:
let mut esi = EsiBuilder::new()
.user_agent("some user agent")
.spec(Some(your_spec))
.build()
.unwrap();Note that this “spec” function is just another builder function; you can make use it alongside all of the others. Note also that this is entirely optional: if you don’t mind retrieving the spec from ESI on each of your struct instances, you can safely ignore this.
§Not including client info
If you are only making calls to non-authenticated endpoints, then you don’t need to make use of the authentication flow, which means you don’t need a client ID, client secret, and callback URL. In this case, you can construct your client without those parameters:
let mut esi = EsiBuilder::new()
.user_agent("some user agent")
.build()
.unwrap();Note that you still need to set the user agent, as this is good API usage behavior.
Implementations§
Source§impl EsiBuilder
impl EsiBuilder
Sourcepub fn compatibility_date(self, val: &str) -> Self
pub fn compatibility_date(self, val: &str) -> Self
Set the compatibility header to use.
Will default to a hardcoded value if not set.
Sourcepub fn client_secret(self, val: &str) -> Self
pub fn client_secret(self, val: &str) -> Self
Set the client_secret (https://docs.esi.evetech.net/docs/sso/web_based_sso_flow.html).
Sourcepub fn enable_application_authentication(self, val: bool) -> Self
pub fn enable_application_authentication(self, val: bool) -> Self
Enable PKCE Authentication flow for Applications (https://docs.esi.evetech.net/docs/sso/native_sso_flow.html)
Sourcepub fn callback_url(self, val: &str) -> Self
pub fn callback_url(self, val: &str) -> Self
Set the callback_url.
Sourcepub fn base_api_url(self, val: &str) -> Self
pub fn base_api_url(self, val: &str) -> Self
Set the base_api_url.
Set the authorize_url.
Sourcepub fn access_token(self, val: Option<&str>) -> Self
pub fn access_token(self, val: Option<&str>) -> Self
Set the access_token.
Sourcepub fn access_expiration(self, val: Option<i64>) -> Self
pub fn access_expiration(self, val: Option<i64>) -> Self
Set the access_expiration.
Sourcepub fn refresh_token(self, val: Option<&str>) -> Self
pub fn refresh_token(self, val: Option<&str>) -> Self
Set the refresh_token.
Sourcepub fn user_agent(self, val: &str) -> Self
pub fn user_agent(self, val: &str) -> Self
Set the user_agent.
Sourcepub fn http_timeout(self, val: Option<u64>) -> Self
pub fn http_timeout(self, val: Option<u64>) -> Self
Set the timeout to use in millis when sending HTTP requests.
Will default to 60,000 (1 minute) if not set.
Sourcepub fn spec(self, spec: Option<Spec>) -> Self
pub fn spec(self, spec: Option<Spec>) -> Self
Explicitly set the OpenAPI specification.
Allows copying the spec from another Esi struct
or other source, avoiding fetching the spec from
ESI again. May be useful given the runtime cost
of retrieving the spec.
Be aware of the potential for out-of-date data.
Sourcepub fn cache_max_entries(self, val: usize) -> Self
pub fn cache_max_entries(self, val: usize) -> Self
Limit how many responses the cache keeps (1024 by default). When it is
full, expired entries are dropped first and then the oldest ones.
Has no effect unless the cache is enabled with EsiBuilder::enable_cache.
Sourcepub fn cache_max_bytes(self, val: usize) -> Self
pub fn cache_max_bytes(self, val: usize) -> Self
Limit how many bytes the cache keeps (no limit by default), counting the
bodies, validators, headers and keys it stores. It applies together with
EsiBuilder::cache_max_entries: when a response does not fit in either
limit, entries are dropped in the same order. A response larger than the
limit by itself is not cached. Has no effect unless the cache is enabled
with EsiBuilder::enable_cache.
Sourcepub fn rate_limit_policy(self, val: RateLimitPolicy) -> Self
pub fn rate_limit_policy(self, val: RateLimitPolicy) -> Self
Choose what the client does when a route group has no rate-limit tokens
left for a request (RateLimitPolicy::Off by default): wait until the
request fits, or fail without calling ESI.
The balance is tracked per route group and access token, from the
X-Ratelimit-* headers of the responses, and only for operations that
declare a group in the spec, so the spec must be loaded.
Sourcepub fn page_concurrency(self, val: usize) -> Self
pub fn page_concurrency(self, val: usize) -> Self
How many pages Esi::fetch_all_pages requests at the same time once it
knows the page count (4 by default; 1 makes it sequential).
Sourcepub fn language(self, val: Language) -> Self
pub fn language(self, val: Language) -> Self
Set the language of the responses (the Accept-Language header).
ESI answers in English when it is not set.
Sourcepub fn tenant(self, val: &str) -> Self
pub fn tenant(self, val: &str) -> Self
Set the tenant (the X-Tenant header). ESI uses tranquility when it is
not set.
Sourcepub fn enable_cache(self, val: bool) -> Self
pub fn enable_cache(self, val: bool) -> Self
Keep GET responses in memory and revalidate them with ETag /
Last-Modified (disabled by default).
While an entry is younger than the operation’s x-client-cache-ttl in the
spec (or the max-age of the response when the spec has none) it is served
without calling ESI; afterwards it is revalidated and a 304 Not Modified
reuses the stored body. Entries are kept per access token.
Trait Implementations§
Source§impl Clone for EsiBuilder
impl Clone for EsiBuilder
Source§impl Debug for EsiBuilder
impl Debug for EsiBuilder
Source§impl Default for EsiBuilder
impl Default for EsiBuilder
Source§impl<'de> Deserialize<'de> for EsiBuilder
impl<'de> Deserialize<'de> for EsiBuilder
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for EsiBuilder
Source§impl PartialEq for EsiBuilder
impl PartialEq for EsiBuilder
Source§impl Serialize for EsiBuilder
impl Serialize for EsiBuilder
impl StructuralPartialEq for EsiBuilder
Auto Trait Implementations§
impl Freeze for EsiBuilder
impl RefUnwindSafe for EsiBuilder
impl Send for EsiBuilder
impl Sync for EsiBuilder
impl Unpin for EsiBuilder
impl UnsafeUnpin for EsiBuilder
impl UnwindSafe for EsiBuilder
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.