Skip to main content

nil_client/client/npc/
precursor.rs

1// Copyright (C) Call of Nil contributors
2// SPDX-License-Identifier: AGPL-3.0-only
3
4use crate::client::Client;
5use crate::error::Result;
6use crate::http;
7use nil_core::continent::Coord;
8use nil_core::npc::precursor::PublicPrecursor;
9use nil_payload::npc::precursor::*;
10
11impl Client {
12  pub async fn get_precursor_coords(&self, req: GetPrecursorCoordsRequest) -> Result<Vec<Coord>> {
13    http::json_put("get-precursor-coords")
14      .body(req)
15      .server(self.server)
16      .circuit_breaker(self.circuit_breaker())
17      .retry(&self.retry)
18      .user_agent(&self.user_agent)
19      .send()
20      .await
21  }
22
23  pub async fn get_public_precursor(
24    &self,
25    req: GetPublicPrecursorRequest,
26  ) -> Result<PublicPrecursor> {
27    http::json_put("get-public-precursor")
28      .body(req)
29      .server(self.server)
30      .circuit_breaker(self.circuit_breaker())
31      .retry(&self.retry)
32      .user_agent(&self.user_agent)
33      .send()
34      .await
35  }
36
37  pub async fn get_public_precursors(
38    &self,
39    req: GetPublicPrecursorsRequest,
40  ) -> Result<Vec<PublicPrecursor>> {
41    http::json_put("get-public-precursors")
42      .body(req)
43      .server(self.server)
44      .circuit_breaker(self.circuit_breaker())
45      .retry(&self.retry)
46      .user_agent(&self.user_agent)
47      .send()
48      .await
49  }
50}