renegade_sdk/renegade_wallet_client/
mod.rs1use uuid::Uuid;
4
5use crate::http::RelayerHttpClientError;
6
7pub mod actions;
8pub mod client;
9pub mod config;
10pub(crate) mod conversions;
11pub(crate) mod utils;
12pub mod websocket;
13
14#[derive(Debug, thiserror::Error)]
16pub enum RenegadeClientError {
17 #[error("error: {0}")]
19 Custom(String),
20 #[error("invalid order: {0}")]
22 InvalidOrder(String),
23 #[error("invalid order update: {0}")]
25 InvalidOrderUpdate(String),
26 #[error("failed to sign message: {0}")]
28 Signing(String),
29 #[error("not admin client")]
31 NotAdmin,
32 #[error("relayer error: {0}")]
34 Relayer(RelayerHttpClientError),
35 #[error("serde error: {0}")]
37 Serde(String),
38 #[error("failed to setup wallet: {0}")]
40 Setup(String),
41 #[error("task error: task {task_id}: {message}")]
43 Task {
44 task_id: Uuid,
46 message: String,
48 },
49 #[error("websocket topic subscription error: {0}")]
51 Subscription(String),
52 #[error("websocket error: {0}")]
54 Websocket(String),
55}
56
57impl RenegadeClientError {
58 #[allow(clippy::needless_pass_by_value)]
60 pub fn custom<T: ToString>(msg: T) -> Self {
61 Self::Custom(msg.to_string())
62 }
63
64 #[allow(clippy::needless_pass_by_value)]
66 pub fn invalid_order<T: ToString>(msg: T) -> Self {
67 Self::InvalidOrder(msg.to_string())
68 }
69
70 #[allow(clippy::needless_pass_by_value)]
72 pub fn invalid_order_update<T: ToString>(msg: T) -> Self {
73 Self::InvalidOrderUpdate(msg.to_string())
74 }
75
76 #[allow(clippy::needless_pass_by_value)]
78 pub fn signing<T: ToString>(msg: T) -> Self {
79 Self::Signing(msg.to_string())
80 }
81
82 #[allow(clippy::needless_pass_by_value)]
84 pub fn setup<T: ToString>(msg: T) -> Self {
85 Self::Setup(msg.to_string())
86 }
87
88 #[allow(clippy::needless_pass_by_value)]
90 pub fn serde<T: ToString>(msg: T) -> Self {
91 Self::Serde(msg.to_string())
92 }
93
94 #[allow(clippy::needless_pass_by_value)]
96 pub fn task<T: ToString>(task_id: Uuid, msg: T) -> Self {
97 Self::Task { task_id, message: msg.to_string() }
98 }
99
100 #[allow(clippy::needless_pass_by_value)]
102 pub fn subscription<T: ToString>(msg: T) -> Self {
103 Self::Subscription(msg.to_string())
104 }
105
106 #[allow(clippy::needless_pass_by_value)]
108 pub fn websocket<T: ToString>(msg: T) -> Self {
109 Self::Websocket(msg.to_string())
110 }
111}
112
113impl From<RelayerHttpClientError> for RenegadeClientError {
114 fn from(err: RelayerHttpClientError) -> Self {
115 Self::Relayer(err)
116 }
117}