arpy_client/
lib.rs

1//! Portable client for Arpy.
2use std::fmt::{Debug, Display};
3
4use futures::Future;
5use thiserror::Error;
6
7pub mod websocket;
8
9/// The errors that can happen during an RPC.
10///
11/// Note; This may contain sensitive information such as URLs or argument
12/// names/values.
13#[derive(Error, Debug, Clone)]
14pub enum Error {
15    #[error("Couldn't deserialize result: {0}")]
16    DeserializeResult(String),
17    #[error("Couldn't send request: {0}")]
18    Send(String),
19    #[error("Couldn't receive response: {0}")]
20    Receive(String),
21    #[error("Invalid response 'content_type'")]
22    UnknownContentType(String),
23}
24
25impl Error {
26    pub fn send(e: impl Display) -> Self {
27        Self::Send(e.to_string())
28    }
29
30    pub fn receive(e: impl Display) -> Self {
31        Self::Receive(e.to_string())
32    }
33
34    pub fn deserialize_result(e: impl Display) -> Self {
35        Self::DeserializeResult(e.to_string())
36    }
37}
38
39pub trait Spawner {
40    fn spawn_local<F>(&self, future: F)
41    where
42        F: Future<Output = ()> + 'static;
43}