Skip to main content

StClient

Struct StClient 

Source
pub struct StClient { /* private fields */ }

Implementations§

Source§

impl StClient

Source

pub fn new(base_url: &str, token: String, scheduler: RequestScheduler) -> Self

Construct a client against base_url (e.g. https://api.spacetraders.io/v2) authenticated with token, sharing the given RequestScheduler for rate limiting. Clone a single scheduler across clients to share one budget.

use spacetraders_client::{RequestScheduler, StClient};

let client = StClient::new(
    "https://api.spacetraders.io/v2",
    std::env::var("AGENT_TOKEN").unwrap(),
    RequestScheduler::new(2), // sustained requests per second
);
Source

pub fn set_token(&mut self, token: String)

Source

pub fn token(&self) -> &str

Source§

impl StClient

Source§

impl StClient

Source§

impl StClient

Source

pub async fn get_contracts( &self, limit: Option<NonZeroU64>, page: Option<NonZeroU64>, ) -> Result<GetContractsResponse, ClientError>

Source

pub async fn get_contracts_with_priority( &self, limit: Option<NonZeroU64>, page: Option<NonZeroU64>, priority: RequestPriority, ) -> Result<GetContractsResponse, ClientError>

Source

pub async fn get_contract( &self, contract_id: &str, ) -> Result<GetContractResponse, ClientError>

Source

pub async fn get_contract_with_priority( &self, contract_id: &str, priority: RequestPriority, ) -> Result<GetContractResponse, ClientError>

Source

pub async fn accept_contract( &self, contract_id: &str, ) -> Result<AcceptContractResponse, ClientError>

Source

pub async fn accept_contract_with_priority( &self, contract_id: &str, priority: RequestPriority, ) -> Result<AcceptContractResponse, ClientError>

Source

pub async fn deliver_contract( &self, contract_id: &str, ship_symbol: &str, trade_symbol: &str, units: NonZeroU64, ) -> Result<DeliverContractResponse, ClientError>

Source

pub async fn deliver_contract_with_priority( &self, contract_id: &str, ship_symbol: &str, trade_symbol: &str, units: NonZeroU64, priority: RequestPriority, ) -> Result<DeliverContractResponse, ClientError>

Source

pub async fn fulfill_contract( &self, contract_id: &str, ) -> Result<FulfillContractResponse, ClientError>

Source

pub async fn fulfill_contract_with_priority( &self, contract_id: &str, priority: RequestPriority, ) -> Result<FulfillContractResponse, ClientError>

Source§

impl StClient

Source

pub async fn jettison( &self, ship_symbol: &str, symbol: TradeSymbol, units: NonZeroU64, ) -> Result<JettisonResponse, ClientError>

Source

pub async fn jettison_with_priority( &self, ship_symbol: &str, symbol: TradeSymbol, units: NonZeroU64, priority: RequestPriority, ) -> Result<JettisonResponse, ClientError>

Source

pub async fn sell_cargo( &self, ship_symbol: &str, symbol: TradeSymbol, units: NonZeroU64, ) -> Result<SellCargo201Response, ClientError>

Source

pub async fn sell_cargo_with_priority( &self, ship_symbol: &str, symbol: TradeSymbol, units: NonZeroU64, priority: RequestPriority, ) -> Result<SellCargo201Response, ClientError>

Source

pub async fn purchase_cargo( &self, ship_symbol: &str, symbol: TradeSymbol, units: NonZeroU64, ) -> Result<PurchaseCargo201Response, ClientError>

Source

pub async fn purchase_cargo_with_priority( &self, ship_symbol: &str, symbol: TradeSymbol, units: NonZeroU64, priority: RequestPriority, ) -> Result<PurchaseCargo201Response, ClientError>

Source

pub async fn transfer_cargo( &self, ship_symbol: &str, trade_symbol: TradeSymbol, units: NonZeroU64, target_ship_symbol: &str, ) -> Result<TransferCargo200Response, ClientError>

Source

pub async fn transfer_cargo_with_priority( &self, ship_symbol: &str, trade_symbol: TradeSymbol, units: NonZeroU64, target_ship_symbol: &str, priority: RequestPriority, ) -> Result<TransferCargo200Response, ClientError>

Source

pub async fn negotiate_contract( &self, ship_symbol: &str, ) -> Result<NegotiateContract201Response, ClientError>

Source

pub async fn negotiate_contract_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<NegotiateContract201Response, ClientError>

Source§

impl StClient

Source

pub async fn get_mounts( &self, ship_symbol: &str, ) -> Result<GetMounts200Response, ClientError>

Source

pub async fn get_mounts_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<GetMounts200Response, ClientError>

Source

pub async fn install_mount( &self, ship_symbol: &str, symbol: &str, ) -> Result<InstallMount201Response, ClientError>

Source

pub async fn install_mount_with_priority( &self, ship_symbol: &str, symbol: &str, priority: RequestPriority, ) -> Result<InstallMount201Response, ClientError>

Source

pub async fn remove_mount( &self, ship_symbol: &str, symbol: &str, ) -> Result<RemoveMount201Response, ClientError>

Source

pub async fn remove_mount_with_priority( &self, ship_symbol: &str, symbol: &str, priority: RequestPriority, ) -> Result<RemoveMount201Response, ClientError>

Source

pub async fn get_repair_ship( &self, ship_symbol: &str, ) -> Result<GetRepairShipResponse, ClientError>

Source

pub async fn get_repair_ship_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<GetRepairShipResponse, ClientError>

Source

pub async fn repair_ship( &self, ship_symbol: &str, ) -> Result<RepairShipResponse, ClientError>

Source

pub async fn repair_ship_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<RepairShipResponse, ClientError>

Source

pub async fn get_scrap_ship( &self, ship_symbol: &str, ) -> Result<GetScrapShipResponse, ClientError>

Source

pub async fn get_scrap_ship_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<GetScrapShipResponse, ClientError>

Source

pub async fn scrap_ship( &self, ship_symbol: &str, ) -> Result<ScrapShipResponse, ClientError>

Source

pub async fn scrap_ship_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<ScrapShipResponse, ClientError>

Source

pub async fn get_ship_modules( &self, ship_symbol: &str, ) -> Result<GetShipModulesResponse, ClientError>

Source

pub async fn get_ship_modules_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<GetShipModulesResponse, ClientError>

Source

pub async fn install_ship_module( &self, ship_symbol: &str, symbol: &str, ) -> Result<InstallShipModuleResponse, ClientError>

Source

pub async fn install_ship_module_with_priority( &self, ship_symbol: &str, symbol: &str, priority: RequestPriority, ) -> Result<InstallShipModuleResponse, ClientError>

Source

pub async fn remove_ship_module( &self, ship_symbol: &str, symbol: &str, ) -> Result<RemoveShipModuleResponse, ClientError>

Source

pub async fn remove_ship_module_with_priority( &self, ship_symbol: &str, symbol: &str, priority: RequestPriority, ) -> Result<RemoveShipModuleResponse, ClientError>

Source

pub async fn create_ship_ship_scan( &self, ship_symbol: &str, ) -> Result<CreateShipShipScanResponse, ClientError>

Source

pub async fn create_ship_ship_scan_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<CreateShipShipScanResponse, ClientError>

Source

pub async fn create_ship_system_scan( &self, ship_symbol: &str, ) -> Result<CreateShipSystemScanResponse, ClientError>

Source

pub async fn create_ship_system_scan_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<CreateShipSystemScanResponse, ClientError>

Source

pub async fn create_ship_waypoint_scan( &self, ship_symbol: &str, ) -> Result<CreateShipWaypointScanResponse, ClientError>

Source

pub async fn create_ship_waypoint_scan_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<CreateShipWaypointScanResponse, ClientError>

Source§

impl StClient

Source

pub async fn extract_resources( &self, ship_symbol: &str, ) -> Result<ExtractResourcesResponse, ClientError>

Source

pub async fn extract_resources_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<ExtractResourcesResponse, ClientError>

Source

pub async fn siphon_resources( &self, ship_symbol: &str, ) -> Result<SiphonResourcesResponse, ClientError>

Source

pub async fn siphon_resources_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<SiphonResourcesResponse, ClientError>

Source

pub async fn extract_resources_with_survey( &self, ship_symbol: &str, survey: &Survey, ) -> Result<ExtractResourcesWithSurveyResponse, ClientError>

Source

pub async fn extract_resources_with_survey_with_priority( &self, ship_symbol: &str, survey: &Survey, priority: RequestPriority, ) -> Result<ExtractResourcesWithSurveyResponse, ClientError>

Source

pub async fn create_survey( &self, ship_symbol: &str, ) -> Result<CreateSurveyResponse, ClientError>

Source

pub async fn create_survey_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<CreateSurveyResponse, ClientError>

Source

pub async fn create_chart( &self, ship_symbol: &str, ) -> Result<CreateChartResponse, ClientError>

Source

pub async fn create_chart_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<CreateChartResponse, ClientError>

Source

pub async fn ship_refine( &self, ship_symbol: &str, produce: &str, ) -> Result<ShipRefine201Response, ClientError>

Source

pub async fn ship_refine_with_priority( &self, ship_symbol: &str, produce: &str, priority: RequestPriority, ) -> Result<ShipRefine201Response, ClientError>

Source§

impl StClient

Source

pub async fn get_my_ships( &self, limit: Option<NonZeroU64>, page: Option<NonZeroU64>, ) -> Result<GetMyShipsResponse, ClientError>

Source

pub async fn get_my_ships_with_priority( &self, limit: Option<NonZeroU64>, page: Option<NonZeroU64>, priority: RequestPriority, ) -> Result<GetMyShipsResponse, ClientError>

Source

pub async fn purchase_ship( &self, ship_type: ShipType, waypoint_symbol: &str, ) -> Result<PurchaseShipResponse, ClientError>

Source

pub async fn purchase_ship_with_priority( &self, ship_type: ShipType, waypoint_symbol: &str, priority: RequestPriority, ) -> Result<PurchaseShipResponse, ClientError>

Source

pub async fn get_my_ship( &self, ship_symbol: &str, ) -> Result<GetMyShipResponse, ClientError>

Source

pub async fn get_my_ship_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<GetMyShipResponse, ClientError>

Source

pub async fn get_my_ship_cargo( &self, ship_symbol: &str, ) -> Result<GetMyShipCargoResponse, ClientError>

Source

pub async fn get_my_ship_cargo_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<GetMyShipCargoResponse, ClientError>

Source

pub async fn orbit_ship( &self, ship_symbol: &str, ) -> Result<OrbitShip200Response, ClientError>

Source

pub async fn orbit_ship_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<OrbitShip200Response, ClientError>

Source

pub async fn dock_ship( &self, ship_symbol: &str, ) -> Result<DockShip200Response, ClientError>

Source

pub async fn dock_ship_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<DockShip200Response, ClientError>

Source

pub async fn navigate_ship( &self, ship_symbol: &str, waypoint_symbol: &str, ) -> Result<NavigateShipResponse, ClientError>

Source

pub async fn navigate_ship_with_priority( &self, ship_symbol: &str, waypoint_symbol: &str, priority: RequestPriority, ) -> Result<NavigateShipResponse, ClientError>

Source

pub async fn refuel_ship( &self, ship_symbol: &str, units: Option<NonZeroU64>, from_cargo: bool, ) -> Result<RefuelShipResponse, ClientError>

Source

pub async fn refuel_ship_with_priority( &self, ship_symbol: &str, units: Option<NonZeroU64>, from_cargo: bool, priority: RequestPriority, ) -> Result<RefuelShipResponse, ClientError>

Source

pub async fn get_ship_cooldown( &self, ship_symbol: &str, ) -> Result<GetShipCooldownResponse, ClientError>

Source

pub async fn get_ship_cooldown_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<GetShipCooldownResponse, ClientError>

Source

pub async fn get_ship_nav( &self, ship_symbol: &str, ) -> Result<GetShipNavResponse, ClientError>

Source

pub async fn get_ship_nav_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<GetShipNavResponse, ClientError>

Source

pub async fn patch_ship_nav( &self, ship_symbol: &str, flight_mode: Option<ShipNavFlightMode>, ) -> Result<PatchShipNavResponse, ClientError>

Source

pub async fn patch_ship_nav_with_priority( &self, ship_symbol: &str, flight_mode: Option<ShipNavFlightMode>, priority: RequestPriority, ) -> Result<PatchShipNavResponse, ClientError>

Source

pub async fn jump_ship( &self, ship_symbol: &str, waypoint_symbol: &str, ) -> Result<JumpShipResponse, ClientError>

Source

pub async fn jump_ship_with_priority( &self, ship_symbol: &str, waypoint_symbol: &str, priority: RequestPriority, ) -> Result<JumpShipResponse, ClientError>

Source

pub async fn warp_ship( &self, ship_symbol: &str, waypoint_symbol: &str, ) -> Result<WarpShipResponse, ClientError>

Source

pub async fn warp_ship_with_priority( &self, ship_symbol: &str, waypoint_symbol: &str, priority: RequestPriority, ) -> Result<WarpShipResponse, ClientError>

Source§

impl StClient

Source§

impl StClient

Source§

impl StClient

Source

pub async fn get_systems( &self, limit: Option<NonZeroU64>, page: Option<NonZeroU64>, ) -> Result<GetSystemsResponse, ClientError>

Source

pub async fn get_systems_with_priority( &self, limit: Option<NonZeroU64>, page: Option<NonZeroU64>, priority: RequestPriority, ) -> Result<GetSystemsResponse, ClientError>

Source

pub async fn get_system( &self, system_symbol: &str, ) -> Result<GetSystemResponse, ClientError>

Source

pub async fn get_system_with_priority( &self, system_symbol: &str, priority: RequestPriority, ) -> Result<GetSystemResponse, ClientError>

Source

pub async fn get_system_waypoints( &self, system_symbol: &str, limit: Option<NonZeroU64>, page: Option<NonZeroU64>, traits: Option<&GetSystemWaypointsTraits>, type_: Option<WaypointType>, ) -> Result<GetSystemWaypointsResponse, ClientError>

Source

pub async fn get_system_waypoints_with_priority( &self, system_symbol: &str, limit: Option<NonZeroU64>, page: Option<NonZeroU64>, traits: Option<&GetSystemWaypointsTraits>, type_: Option<WaypointType>, priority: RequestPriority, ) -> Result<GetSystemWaypointsResponse, ClientError>

Source

pub async fn get_waypoint( &self, system_symbol: &str, waypoint_symbol: &str, ) -> Result<GetWaypointResponse, ClientError>

Source

pub async fn get_waypoint_with_priority( &self, system_symbol: &str, waypoint_symbol: &str, priority: RequestPriority, ) -> Result<GetWaypointResponse, ClientError>

Source

pub async fn get_market( &self, system_symbol: &str, waypoint_symbol: &str, ) -> Result<GetMarketResponse, ClientError>

Source

pub async fn get_market_with_priority( &self, system_symbol: &str, waypoint_symbol: &str, priority: RequestPriority, ) -> Result<GetMarketResponse, ClientError>

Source

pub async fn get_shipyard( &self, system_symbol: &str, waypoint_symbol: &str, ) -> Result<GetShipyardResponse, ClientError>

Source

pub async fn get_shipyard_with_priority( &self, system_symbol: &str, waypoint_symbol: &str, priority: RequestPriority, ) -> Result<GetShipyardResponse, ClientError>

Source

pub async fn get_jump_gate( &self, system_symbol: &str, waypoint_symbol: &str, ) -> Result<GetJumpGateResponse, ClientError>

Source

pub async fn get_jump_gate_with_priority( &self, system_symbol: &str, waypoint_symbol: &str, priority: RequestPriority, ) -> Result<GetJumpGateResponse, ClientError>

Source

pub async fn get_construction( &self, system_symbol: &str, waypoint_symbol: &str, ) -> Result<GetConstructionResponse, ClientError>

Source

pub async fn get_construction_with_priority( &self, system_symbol: &str, waypoint_symbol: &str, priority: RequestPriority, ) -> Result<GetConstructionResponse, ClientError>

Source

pub async fn supply_construction( &self, system_symbol: &str, waypoint_symbol: &str, ship_symbol: &str, trade_symbol: TradeSymbol, units: NonZeroU64, ) -> Result<SupplyConstructionResponse, ClientError>

Source

pub async fn supply_construction_with_priority( &self, system_symbol: &str, waypoint_symbol: &str, ship_symbol: &str, trade_symbol: TradeSymbol, units: NonZeroU64, priority: RequestPriority, ) -> Result<SupplyConstructionResponse, ClientError>

Auto Trait Implementations§

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> 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: Sized + 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: Sized + 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, 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<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