Struct exocore_discovery::client::Client
source · pub struct Client { /* private fields */ }
Expand description
Discovery service client.
The discovery service is a simple REST API on which clients can push temporary payload for which the server generates a random PIN. Another client can then retrieve that payload by using the generated random PIN. Once a payload is consumed, it is deleted.
Implementations§
source§impl Client
impl Client
sourcepub async fn create(
&self,
payload: &[u8],
expect_reply: bool
) -> Result<CreatePayloadResponse, Error>
pub async fn create( &self, payload: &[u8], expect_reply: bool ) -> Result<CreatePayloadResponse, Error>
Creates a new payload on the server. If successfully created, the response contains a unique pin that can be used by another client to retrieve the payload.
sourcepub async fn get<P: TryInto<Pin>>(&self, pin: P) -> Result<Payload, Error>
pub async fn get<P: TryInto<Pin>>(&self, pin: P) -> Result<Payload, Error>
Gets a payload by unique pin created by the call to create
by another
client.
sourcepub async fn get_loop<P: TryInto<Pin>>(
&self,
pin: P,
timeout: Duration
) -> Result<Payload, Error>
pub async fn get_loop<P: TryInto<Pin>>( &self, pin: P, timeout: Duration ) -> Result<Payload, Error>
Gets a payload by unique pin created by the call to create
by another
client and retries fetching if it hasn’t been found it until
timeout
.
sourcepub async fn reply(
&self,
reply_pin: Pin,
reply_token: ReplyToken,
payload: &[u8],
expect_reply: bool
) -> Result<CreatePayloadResponse, Error>
pub async fn reply( &self, reply_pin: Pin, reply_token: ReplyToken, payload: &[u8], expect_reply: bool ) -> Result<CreatePayloadResponse, Error>
Replies to a payload on the server using the given reply pin and authentication token. If successfully created, the response contains can be retrieved using the reply pin.