pub struct StClient { /* private fields */ }Implementations§
Source§impl StClient
impl StClient
Sourcepub fn new(base_url: &str, token: String, scheduler: RequestScheduler) -> Self
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
);pub fn set_token(&mut self, token: String)
pub fn token(&self) -> &str
Source§impl StClient
impl StClient
pub async fn get_factions( &self, limit: Option<NonZeroU64>, page: Option<NonZeroU64>, ) -> Result<GetFactionsResponse, ClientError>
pub async fn get_factions_with_priority( &self, limit: Option<NonZeroU64>, page: Option<NonZeroU64>, priority: RequestPriority, ) -> Result<GetFactionsResponse, ClientError>
pub async fn get_faction( &self, faction_symbol: &str, ) -> Result<GetFactionResponse, ClientError>
pub async fn get_faction_with_priority( &self, faction_symbol: &str, priority: RequestPriority, ) -> Result<GetFactionResponse, ClientError>
pub async fn get_my_factions( &self, limit: Option<NonZeroU64>, page: Option<NonZeroU64>, ) -> Result<GetMyFactionsResponse, ClientError>
pub async fn get_my_factions_with_priority( &self, limit: Option<NonZeroU64>, page: Option<NonZeroU64>, priority: RequestPriority, ) -> Result<GetMyFactionsResponse, ClientError>
Source§impl StClient
impl StClient
pub async fn register( &self, symbol: &str, faction: FactionSymbol, ) -> Result<RegisterResponse, ClientError>
pub async fn register_with_priority( &self, symbol: &str, faction: FactionSymbol, priority: RequestPriority, ) -> Result<RegisterResponse, ClientError>
pub async fn my_agent(&self) -> Result<GetMyAgentResponse, ClientError>
pub async fn my_agent_with_priority( &self, priority: RequestPriority, ) -> Result<GetMyAgentResponse, ClientError>
pub async fn get_agents( &self, limit: Option<NonZeroU64>, page: Option<NonZeroU64>, ) -> Result<GetAgentsResponse, ClientError>
pub async fn get_agents_with_priority( &self, limit: Option<NonZeroU64>, page: Option<NonZeroU64>, priority: RequestPriority, ) -> Result<GetAgentsResponse, ClientError>
pub async fn get_agent( &self, agent_symbol: &str, ) -> Result<GetAgentResponse, ClientError>
pub async fn get_agent_with_priority( &self, agent_symbol: &str, priority: RequestPriority, ) -> Result<GetAgentResponse, ClientError>
pub async fn get_my_agent_events( &self, ) -> Result<GetMyAgentEventsResponse, ClientError>
pub async fn get_my_agent_events_with_priority( &self, priority: RequestPriority, ) -> Result<GetMyAgentEventsResponse, ClientError>
pub async fn get_my_account(&self) -> Result<GetMyAccountResponse, ClientError>
pub async fn get_my_account_with_priority( &self, priority: RequestPriority, ) -> Result<GetMyAccountResponse, ClientError>
Source§impl StClient
impl StClient
pub async fn get_contracts( &self, limit: Option<NonZeroU64>, page: Option<NonZeroU64>, ) -> Result<GetContractsResponse, ClientError>
pub async fn get_contracts_with_priority( &self, limit: Option<NonZeroU64>, page: Option<NonZeroU64>, priority: RequestPriority, ) -> Result<GetContractsResponse, ClientError>
pub async fn get_contract( &self, contract_id: &str, ) -> Result<GetContractResponse, ClientError>
pub async fn get_contract_with_priority( &self, contract_id: &str, priority: RequestPriority, ) -> Result<GetContractResponse, ClientError>
pub async fn accept_contract( &self, contract_id: &str, ) -> Result<AcceptContractResponse, ClientError>
pub async fn accept_contract_with_priority( &self, contract_id: &str, priority: RequestPriority, ) -> Result<AcceptContractResponse, ClientError>
pub async fn deliver_contract( &self, contract_id: &str, ship_symbol: &str, trade_symbol: &str, units: NonZeroU64, ) -> Result<DeliverContractResponse, ClientError>
pub async fn deliver_contract_with_priority( &self, contract_id: &str, ship_symbol: &str, trade_symbol: &str, units: NonZeroU64, priority: RequestPriority, ) -> Result<DeliverContractResponse, ClientError>
pub async fn fulfill_contract( &self, contract_id: &str, ) -> Result<FulfillContractResponse, ClientError>
pub async fn fulfill_contract_with_priority( &self, contract_id: &str, priority: RequestPriority, ) -> Result<FulfillContractResponse, ClientError>
Source§impl StClient
impl StClient
pub async fn jettison( &self, ship_symbol: &str, symbol: TradeSymbol, units: NonZeroU64, ) -> Result<JettisonResponse, ClientError>
pub async fn jettison_with_priority( &self, ship_symbol: &str, symbol: TradeSymbol, units: NonZeroU64, priority: RequestPriority, ) -> Result<JettisonResponse, ClientError>
pub async fn sell_cargo( &self, ship_symbol: &str, symbol: TradeSymbol, units: NonZeroU64, ) -> Result<SellCargo201Response, ClientError>
pub async fn sell_cargo_with_priority( &self, ship_symbol: &str, symbol: TradeSymbol, units: NonZeroU64, priority: RequestPriority, ) -> Result<SellCargo201Response, ClientError>
pub async fn purchase_cargo( &self, ship_symbol: &str, symbol: TradeSymbol, units: NonZeroU64, ) -> Result<PurchaseCargo201Response, ClientError>
pub async fn purchase_cargo_with_priority( &self, ship_symbol: &str, symbol: TradeSymbol, units: NonZeroU64, priority: RequestPriority, ) -> Result<PurchaseCargo201Response, ClientError>
pub async fn transfer_cargo( &self, ship_symbol: &str, trade_symbol: TradeSymbol, units: NonZeroU64, target_ship_symbol: &str, ) -> Result<TransferCargo200Response, ClientError>
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>
pub async fn negotiate_contract( &self, ship_symbol: &str, ) -> Result<NegotiateContract201Response, ClientError>
pub async fn negotiate_contract_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<NegotiateContract201Response, ClientError>
Source§impl StClient
impl StClient
pub async fn get_mounts( &self, ship_symbol: &str, ) -> Result<GetMounts200Response, ClientError>
pub async fn get_mounts_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<GetMounts200Response, ClientError>
pub async fn install_mount( &self, ship_symbol: &str, symbol: &str, ) -> Result<InstallMount201Response, ClientError>
pub async fn install_mount_with_priority( &self, ship_symbol: &str, symbol: &str, priority: RequestPriority, ) -> Result<InstallMount201Response, ClientError>
pub async fn remove_mount( &self, ship_symbol: &str, symbol: &str, ) -> Result<RemoveMount201Response, ClientError>
pub async fn remove_mount_with_priority( &self, ship_symbol: &str, symbol: &str, priority: RequestPriority, ) -> Result<RemoveMount201Response, ClientError>
pub async fn get_repair_ship( &self, ship_symbol: &str, ) -> Result<GetRepairShipResponse, ClientError>
pub async fn get_repair_ship_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<GetRepairShipResponse, ClientError>
pub async fn repair_ship( &self, ship_symbol: &str, ) -> Result<RepairShipResponse, ClientError>
pub async fn repair_ship_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<RepairShipResponse, ClientError>
pub async fn get_scrap_ship( &self, ship_symbol: &str, ) -> Result<GetScrapShipResponse, ClientError>
pub async fn get_scrap_ship_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<GetScrapShipResponse, ClientError>
pub async fn scrap_ship( &self, ship_symbol: &str, ) -> Result<ScrapShipResponse, ClientError>
pub async fn scrap_ship_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<ScrapShipResponse, ClientError>
pub async fn get_ship_modules( &self, ship_symbol: &str, ) -> Result<GetShipModulesResponse, ClientError>
pub async fn get_ship_modules_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<GetShipModulesResponse, ClientError>
pub async fn install_ship_module( &self, ship_symbol: &str, symbol: &str, ) -> Result<InstallShipModuleResponse, ClientError>
pub async fn install_ship_module_with_priority( &self, ship_symbol: &str, symbol: &str, priority: RequestPriority, ) -> Result<InstallShipModuleResponse, ClientError>
pub async fn remove_ship_module( &self, ship_symbol: &str, symbol: &str, ) -> Result<RemoveShipModuleResponse, ClientError>
pub async fn remove_ship_module_with_priority( &self, ship_symbol: &str, symbol: &str, priority: RequestPriority, ) -> Result<RemoveShipModuleResponse, ClientError>
pub async fn create_ship_ship_scan( &self, ship_symbol: &str, ) -> Result<CreateShipShipScanResponse, ClientError>
pub async fn create_ship_ship_scan_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<CreateShipShipScanResponse, ClientError>
pub async fn create_ship_system_scan( &self, ship_symbol: &str, ) -> Result<CreateShipSystemScanResponse, ClientError>
pub async fn create_ship_system_scan_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<CreateShipSystemScanResponse, ClientError>
pub async fn create_ship_waypoint_scan( &self, ship_symbol: &str, ) -> Result<CreateShipWaypointScanResponse, ClientError>
pub async fn create_ship_waypoint_scan_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<CreateShipWaypointScanResponse, ClientError>
Source§impl StClient
impl StClient
pub async fn extract_resources( &self, ship_symbol: &str, ) -> Result<ExtractResourcesResponse, ClientError>
pub async fn extract_resources_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<ExtractResourcesResponse, ClientError>
pub async fn siphon_resources( &self, ship_symbol: &str, ) -> Result<SiphonResourcesResponse, ClientError>
pub async fn siphon_resources_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<SiphonResourcesResponse, ClientError>
pub async fn extract_resources_with_survey( &self, ship_symbol: &str, survey: &Survey, ) -> Result<ExtractResourcesWithSurveyResponse, ClientError>
pub async fn extract_resources_with_survey_with_priority( &self, ship_symbol: &str, survey: &Survey, priority: RequestPriority, ) -> Result<ExtractResourcesWithSurveyResponse, ClientError>
pub async fn create_survey( &self, ship_symbol: &str, ) -> Result<CreateSurveyResponse, ClientError>
pub async fn create_survey_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<CreateSurveyResponse, ClientError>
pub async fn create_chart( &self, ship_symbol: &str, ) -> Result<CreateChartResponse, ClientError>
pub async fn create_chart_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<CreateChartResponse, ClientError>
pub async fn ship_refine( &self, ship_symbol: &str, produce: &str, ) -> Result<ShipRefine201Response, ClientError>
pub async fn ship_refine_with_priority( &self, ship_symbol: &str, produce: &str, priority: RequestPriority, ) -> Result<ShipRefine201Response, ClientError>
Source§impl StClient
impl StClient
pub async fn get_my_ships( &self, limit: Option<NonZeroU64>, page: Option<NonZeroU64>, ) -> Result<GetMyShipsResponse, ClientError>
pub async fn get_my_ships_with_priority( &self, limit: Option<NonZeroU64>, page: Option<NonZeroU64>, priority: RequestPriority, ) -> Result<GetMyShipsResponse, ClientError>
pub async fn purchase_ship( &self, ship_type: ShipType, waypoint_symbol: &str, ) -> Result<PurchaseShipResponse, ClientError>
pub async fn purchase_ship_with_priority( &self, ship_type: ShipType, waypoint_symbol: &str, priority: RequestPriority, ) -> Result<PurchaseShipResponse, ClientError>
pub async fn get_my_ship( &self, ship_symbol: &str, ) -> Result<GetMyShipResponse, ClientError>
pub async fn get_my_ship_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<GetMyShipResponse, ClientError>
pub async fn get_my_ship_cargo( &self, ship_symbol: &str, ) -> Result<GetMyShipCargoResponse, ClientError>
pub async fn get_my_ship_cargo_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<GetMyShipCargoResponse, ClientError>
pub async fn orbit_ship( &self, ship_symbol: &str, ) -> Result<OrbitShip200Response, ClientError>
pub async fn orbit_ship_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<OrbitShip200Response, ClientError>
pub async fn dock_ship( &self, ship_symbol: &str, ) -> Result<DockShip200Response, ClientError>
pub async fn dock_ship_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<DockShip200Response, ClientError>
pub async fn refuel_ship( &self, ship_symbol: &str, units: Option<NonZeroU64>, from_cargo: bool, ) -> Result<RefuelShipResponse, ClientError>
pub async fn refuel_ship_with_priority( &self, ship_symbol: &str, units: Option<NonZeroU64>, from_cargo: bool, priority: RequestPriority, ) -> Result<RefuelShipResponse, ClientError>
pub async fn get_ship_cooldown( &self, ship_symbol: &str, ) -> Result<GetShipCooldownResponse, ClientError>
pub async fn get_ship_cooldown_with_priority( &self, ship_symbol: &str, priority: RequestPriority, ) -> Result<GetShipCooldownResponse, ClientError>
pub async fn jump_ship( &self, ship_symbol: &str, waypoint_symbol: &str, ) -> Result<JumpShipResponse, ClientError>
pub async fn jump_ship_with_priority( &self, ship_symbol: &str, waypoint_symbol: &str, priority: RequestPriority, ) -> Result<JumpShipResponse, ClientError>
pub async fn warp_ship( &self, ship_symbol: &str, waypoint_symbol: &str, ) -> Result<WarpShipResponse, ClientError>
pub async fn warp_ship_with_priority( &self, ship_symbol: &str, waypoint_symbol: &str, priority: RequestPriority, ) -> Result<WarpShipResponse, ClientError>
Source§impl StClient
impl StClient
pub async fn get_supply_chain( &self, ) -> Result<GetSupplyChainResponse, ClientError>
pub async fn get_supply_chain_with_priority( &self, priority: RequestPriority, ) -> Result<GetSupplyChainResponse, ClientError>
Source§impl StClient
impl StClient
pub async fn status(&self) -> Result<GetStatusResponse, ClientError>
pub async fn status_with_priority( &self, priority: RequestPriority, ) -> Result<GetStatusResponse, ClientError>
pub async fn get_status(&self) -> Result<GetStatusResponse, ClientError>
pub async fn get_status_with_priority( &self, priority: RequestPriority, ) -> Result<GetStatusResponse, ClientError>
pub async fn get_error_codes( &self, ) -> Result<GetErrorCodesResponse, ClientError>
pub async fn get_error_codes_with_priority( &self, priority: RequestPriority, ) -> Result<GetErrorCodesResponse, ClientError>
Source§impl StClient
impl StClient
pub async fn get_systems( &self, limit: Option<NonZeroU64>, page: Option<NonZeroU64>, ) -> Result<GetSystemsResponse, ClientError>
pub async fn get_systems_with_priority( &self, limit: Option<NonZeroU64>, page: Option<NonZeroU64>, priority: RequestPriority, ) -> Result<GetSystemsResponse, ClientError>
pub async fn get_system( &self, system_symbol: &str, ) -> Result<GetSystemResponse, ClientError>
pub async fn get_system_with_priority( &self, system_symbol: &str, priority: RequestPriority, ) -> Result<GetSystemResponse, ClientError>
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>
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>
pub async fn get_waypoint( &self, system_symbol: &str, waypoint_symbol: &str, ) -> Result<GetWaypointResponse, ClientError>
pub async fn get_waypoint_with_priority( &self, system_symbol: &str, waypoint_symbol: &str, priority: RequestPriority, ) -> Result<GetWaypointResponse, ClientError>
pub async fn get_market( &self, system_symbol: &str, waypoint_symbol: &str, ) -> Result<GetMarketResponse, ClientError>
pub async fn get_market_with_priority( &self, system_symbol: &str, waypoint_symbol: &str, priority: RequestPriority, ) -> Result<GetMarketResponse, ClientError>
pub async fn get_shipyard( &self, system_symbol: &str, waypoint_symbol: &str, ) -> Result<GetShipyardResponse, ClientError>
pub async fn get_shipyard_with_priority( &self, system_symbol: &str, waypoint_symbol: &str, priority: RequestPriority, ) -> Result<GetShipyardResponse, ClientError>
pub async fn get_jump_gate( &self, system_symbol: &str, waypoint_symbol: &str, ) -> Result<GetJumpGateResponse, ClientError>
pub async fn get_jump_gate_with_priority( &self, system_symbol: &str, waypoint_symbol: &str, priority: RequestPriority, ) -> Result<GetJumpGateResponse, ClientError>
pub async fn get_construction( &self, system_symbol: &str, waypoint_symbol: &str, ) -> Result<GetConstructionResponse, ClientError>
pub async fn get_construction_with_priority( &self, system_symbol: &str, waypoint_symbol: &str, priority: RequestPriority, ) -> Result<GetConstructionResponse, ClientError>
pub async fn supply_construction( &self, system_symbol: &str, waypoint_symbol: &str, ship_symbol: &str, trade_symbol: TradeSymbol, units: NonZeroU64, ) -> Result<SupplyConstructionResponse, ClientError>
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§
impl !RefUnwindSafe for StClient
impl !UnwindSafe for StClient
impl Freeze for StClient
impl Send for StClient
impl Sync for StClient
impl Unpin for StClient
impl UnsafeUnpin for StClient
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
Mutably borrows from an owned value. Read more