Esi

Struct Esi 

Source
pub struct Esi {
    pub access_token: Option<String>,
    pub access_expiration: Option<i64>,
    pub refresh_token: Option<String>,
    /* private fields */
}
Expand description

Struct to interact with ESI.

Construct an instance of this struct using EsiBuilder.

§Example

use rfesi::prelude::EsiBuilder;
// the struct must be mutable for some functionality
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();

Fields§

§access_token: Option<String>

The access token from ESI, if set.

§access_expiration: Option<i64>

The millisecond unix timestamp after which the access token expires, if present.

§refresh_token: Option<String>

The refresh token from ESI, if set.

Implementations§

Source§

impl Esi

Source

pub async fn update_spec(&mut self) -> EsiResult<()>

Get the Swagger spec from ESI and store it in this struct.

If you are making use of the try_get_endpoint_for_op_id, then this function will be called there when needed (which should only really be when the struct is constructed unless the struct is kept in memory for a very long time). When using get_endpoint_for_op_id however, you are responsible for calling this function beforehand.

§Example
esi.update_spec().await.unwrap();
Source

pub fn get_authorize_url(&self) -> EsiResult<AuthenticationInformation>

Generate and return the URL required for the user to grant you an auth code, as wells as infos for future authentication request.

You can inspect the URL returned by ESI to your web service to ensure it matches. No checking is done by rfesi.

§Example
let auth_info = esi.get_authorize_url().unwrap();
// then send your user to that URL
let url = auth_info.authorization_url;

If you opted to not include client information in the EsiBuilder flow, then this function will return an error instead.

Source

pub async fn authenticate( &mut self, code: &str, pkce_verifier: Option<PkceVerifier>, ) -> EsiResult<Option<TokenClaims>>

Authenticate with ESI, exchanging a code from the authorize flow for an access token that is used to make authenticated calls to ESI.

Note that this is one of the functions that requires the struct be mutable, as the struct mutates to include the resulting access token.

If the “validate_jwt” feature is enabled (by default), then the access token’s claims will be returned. If the feature is not enabled, then the returned value will be None.

§Example (client secret)
let claims = esi.authenticate("abcdef...", None).await.unwrap();
§Example (PKCE/Application authentication)
 async fn run() {
Source

pub async fn use_refresh_token(&mut self, refresh_token: &str) -> EsiResult<()>

Authenticate via a previously-fetched refresh token.

The functionality of a refresh token allows re-authenticating this struct instance without prompting the user to log into EVE SSO again. When the user is authenticated in that manner, a refresh token is returned and available via the refresh_token struct field. Store this securely should you wish to later make authenticate calls for that user.

§Example
esi.use_refresh_token("abcdef...").await.unwrap();
Source

pub async fn refresh_access_token( &mut self, refresh_token: Option<&str>, ) -> EsiResult<()>

Authenticate via a refresh token given as input, or using the internal refresh_token if it’s available.

The functionality of a refresh token allows re-authenticating this struct instance without prompting the user to log into EVE SSO again. When the user is authenticated in that manner, a refresh token is returned and available via the refresh_token struct field. Store this securely should you wish to later make authenticate calls for that user.

§Example with internal token
esi.refresh_access_token(None).await.unwrap();
§Example with input token
esi.refresh_access_token(Some("MyRefreshToken")).await.unwrap();
Source

pub async fn query<T: DeserializeOwned>( &self, method: &str, request_type: RequestType, endpoint: &str, query: Option<&[(&str, &str)]>, body: Option<&str>, ) -> EsiResult<T>

Make a request to ESI.

This is mainly used as the underlying function for this library when making calls to ESI; the other functions that you should primarily be using contain more functionality, including matching endpoint with deserialization struct, evaluating & replacing URL parameters, etc.

In the event that there is not a wrapper function for the endpoint that you want to use, you can use this function to make an API call without waiting for the library to be updated.

§Example
#[derive(Deserialize)]
struct ReturnedData {}
let data: ReturnedData = esi.query("GET", RequestType::Public, "abc", None, None).await.unwrap();
Source

pub async fn try_get_endpoint_for_op_id( &mut self, op_id: &str, ) -> EsiResult<String>

Resolve an operationId to a URL path utilizing the Swagger spec.

If the spec has not yet been retrieved when calling this function, an API call will be made to ESI to fetch that data (thus the async signature of this function). If you don’t need that help (by explicitly making a call to update_spec prior) then you can use the get_endpoint_for_op_id function, which is synchronous.

Note that when making use of this function along with query, you are responsible for resolving any/all URL parameters that the endpoint may contain.

§Example
let endpoint = esi
    .try_get_endpoint_for_op_id("get_alliances_alliance_id_contacts_labels")
    .await
    .unwrap();
Source

pub fn get_endpoint_for_op_id(&self, op_id: &str) -> EsiResult<String>

Resolve an operationId to a URL path utilizing the Swagger spec.

If the spec has not yet been retrieved when calling this function, this function will return an error.

Note that when making use of this function along with query, you are responsible for resolving any/all URL parameters that the endpoint may contain.

§Example
let endpoint = esi.get_endpoint_for_op_id("get_alliances_alliance_id_contacts_labels").unwrap();
Source

pub async fn is_error_limited(&self) -> Result<ErrorLimitStatus, EsiError>

Returns whether we have temporarily encountered the error limit due to too many failed responses.

If this returns true, then this client will refuse to process further requests.

Source

pub fn get_spec(&self) -> Option<&Spec>

Retrieve this struct’s OpenAPI specification.

Use in tandem with EsiBuilder::spec.

Source

pub fn group_alliance(&self) -> AllianceGroup<'_>

Call endpoints under the “alliance” group in ESI.

Source

pub fn group_assets(&self) -> AssetsGroup<'_>

Call endpoints under the “Assets” group in ESI.

Source

pub fn group_bookmarks(&self) -> BookmarksGroup<'_>

Call endpoints under the “Bookmarks” group in ESI.

Source

pub fn group_calendar(&self) -> CalendarGroup<'_>

Call endpoints under the “Calendar” group in ESI.

Source

pub fn group_character(&self) -> CharacterGroup<'_>

Call endpoints under the “Character” group in ESI.

Source

pub fn group_clones(&self) -> ClonesGroup<'_>

Call endpoints under the “Clones” group in ESI.

Source

pub fn group_contacts(&self) -> ContactsGroup<'_>

Call endpoints under the “Contacts” group in ESI.

Source

pub fn group_contracts(&self) -> ContractsGroup<'_>

Call endpoints under the “Contracts” group in ESI.

Source

pub fn group_corporation(&self) -> CorporationGroup<'_>

Call endpoints under the “Corporation” group in ESI.

Source

pub fn group_dogma(&self) -> DogmaGroup<'_>

Call endpoints under the “Dogma” group in ESI.

Source

pub fn group_faction_warfare(&self) -> FactionWarfareGroup<'_>

Call endpoints under the “FactionWarfare” group in ESI.

Source

pub fn group_fittings(&self) -> FittingsGroup<'_>

Call endpoints under the “Fittings” group in ESI.

Source

pub fn group_fleets(&self) -> FleetsGroup<'_>

Call endpoints under the “Fleets” group in ESI.

Source

pub fn group_incursions(&self) -> IncursionsGroup<'_>

Call endpoints under the “Incursions” group in ESI.

Source

pub fn group_industry(&self) -> IndustryGroup<'_>

Call endpoints under the “Industry” group in ESI.

Source

pub fn group_insurance(&self) -> InsuranceGroup<'_>

Call endpoints under the “Insurance” group in ESI.

Source

pub fn group_killmails(&self) -> KillmailsGroup<'_>

Call endpoints under the “Killmails” group in ESI.

Source

pub fn group_location(&self) -> LocationGroup<'_>

Call endpoints under the “Location” group in ESI.

Source

pub fn group_loyalty(&self) -> LoyaltyGroup<'_>

Call endpoints under the “Loyalty” group in ESI.

Source

pub fn group_mail(&self) -> MailGroup<'_>

Call endpoints under the “Mail” group in ESI.

Source

pub fn group_market(&self) -> MarketGroup<'_>

Call endpoints under the “Market” group in ESI.

Source

pub fn group_opportunities(&self) -> OpportunitiesGroup<'_>

Call endpoints under the “Opportunities” group in ESI.

Source

pub fn group_planetary_interaction(&self) -> PlanetaryInteractionGroup<'_>

Call endpoints under the “PlanetaryInteraction” group in ESI.

Source

pub fn group_routes(&self) -> RoutesGroup<'_>

Call endpoints under the “Routes” group in ESI.

Call endpoints under the “Search” group in ESI.

Source

pub fn group_skills(&self) -> SkillsGroup<'_>

Call endpoints under the “Skills” group in ESI.

Source

pub fn group_sovereignty(&self) -> SovereigntyGroup<'_>

Call endpoints under the “Sovereignty” group in ESI.

Source

pub fn group_status(&self) -> StatusGroup<'_>

Call endpoints under the “Status” group in ESI.

Source

pub fn group_universe(&self) -> UniverseGroup<'_>

Call endpoints under the “Universe” group in ESI.

Source

pub fn group_user_interface(&self) -> UserInterfaceGroup<'_>

Call endpoints under the “UserInterface” group in ESI.

Source

pub fn group_wallet(&self) -> WalletGroup<'_>

Call endpoints under the “Wallet” group in ESI.

Source

pub fn group_wars(&self) -> WarsGroup<'_>

Call endpoints under the “Wars” group in ESI.

Trait Implementations§

Source§

impl Clone for Esi

Source§

fn clone(&self) -> Esi

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Esi

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Esi

§

impl !RefUnwindSafe for Esi

§

impl Send for Esi

§

impl Sync for Esi

§

impl Unpin for Esi

§

impl !UnwindSafe for Esi

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,