Struct spacetraders::client::Client[][src]

pub struct Client {
    pub username: String,
    pub token: String,
    // some fields omitted
}

A SpaceTraders client that is associated to a specific username

Fields

username: String

The users username

token: String

The uses access token

Implementations

impl Client[src]

pub fn new(http_client: HttpClient, username: String, token: String) -> Client[src]

Create a new game with a reqwest client that has the Authorization header set

Arguments

  • username - A string containing the username of the current player
  • token - A string containing the access token for the username provided

pub async fn get_flight_plan(&self, id: String) -> Result<FlightPlan, Error>[src]

Get the current details of a flight plan

Arguments

  • id - A string containing the flight plan id

pub async fn create_flight_plan(
    &self,
    ship_id: String,
    destination: String
) -> Result<FlightPlan, Error>
[src]

Create a flight plan.

Arguments

  • ship_id - A string containing the ship_id to create the flight plan for
  • destination - A string containing the location to send the ship to

pub async fn get_game_status(&self) -> Result<GameStatus, Error>[src]

Get the status of the game API.

pub async fn get_available_loans(&self) -> Result<AvailableLoans, Error>[src]

Get all available loans

pub async fn get_your_loans(&self) -> Result<LoanInfo, Error>[src]

Get any loans taken out by the current user

pub async fn pay_off_loan(&self, loan_id: String) -> Result<UserInfo, Error>[src]

Pay off a loan completely

Arguments

  • loan_id - A string containing the loan_id of the loan to pay off

pub async fn request_new_loan(
    &self,
    loan_type: LoanType
) -> Result<RequestLoan, Error>
[src]

Request a new loan

Arguments

  • loan_type - A LoanType with the type of loan being requested for the current user

pub async fn get_location_info(
    &self,
    location: String
) -> Result<LocationInfo, Error>
[src]

Get location info about a specific location

Arguments

  • location - A string containing the location name to get info about

pub async fn get_locations_in_system(
    &self,
    system: String,
    location_type: Option<LocationType>
) -> Result<AvailableLocations, Error>
[src]

Get all the locations in a particular system

Arguments

  • system - A string containing the system name to get the locations from
  • location_type - An optional LocationType if you want to filter the locations by type

pub async fn get_location_marketplace(
    &self,
    location: String
) -> Result<LocationMarketplace, Error>
[src]

Get the marketplace data about a location.

Note

You must have a ship docked at the location in order to get it’s marketplace data

Arguments

  • location - A string containing the name of the location to get marketplace data for

pub async fn create_purchase_order(
    &self,
    ship: Ship,
    good: Good,
    quantity: i32
) -> Result<PurchaseOrder, Error>
[src]

Create a purchase order to transfer goods from a location to your ship

Arguments

  • ship - A Ship struct that you’d like to transfer the goods into
  • good - A Good enum containing the type of good you’d like to transfer
  • quantity - An i32 containing the quantity of good you’d like transferred

pub async fn create_sell_order(
    &self,
    ship_id: String,
    good: Good,
    quantity: i32
) -> Result<PurchaseOrder, Error>
[src]

Create a sell order to transfer good from your ship to a location. Your ship will automatically sell the good to whatever location it is docked at

Arguments

  • ship - A Ship struct that you’d like to transfer the goods from
  • good - A Good enum containing the type of good you’d like to transfer
  • quantity - An i32 containing the quantity of good you’d like transferred

pub async fn purchase_ship(
    &self,
    location: String,
    ship_type: String
) -> Result<PurchaseShip, Error>
[src]

Add a ship to the users inventory by purchasing it

Arguments

  • location - A string containing the location you’d like to purchase the ship from
  • ship_type - A string containing the type of ship you’d like to purchase

pub async fn get_ships_for_sale(&self) -> Result<ShipsForSale, Error>[src]

Get all ships that are available for sale

pub async fn get_your_ships(&self) -> Result<YourShips, Error>[src]

Get all your ships

pub async fn get_systems_info(&self) -> Result<SystemsInfo, Error>[src]

Get information about all systems

pub async fn get_user_info(&self) -> Result<UserInfo, Error>[src]

Get all information about the current user

Trait Implementations

impl Clone for Client[src]

impl Debug for Client[src]

Auto Trait Implementations

impl !RefUnwindSafe for Client

impl Send for Client

impl Sync for Client

impl Unpin for Client

impl !UnwindSafe for Client

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.