aria2_rs_yet/
lib.rs

1pub mod call;
2mod error;
3pub mod options;
4mod ws;
5
6/// https://www.jsonrpc.org/specification
7mod jsonrpc {
8    #[derive(serde::Serialize)]
9    pub struct Request<'a, I, S> {
10        pub jsonrpc: &'a str, // jsonrpc must be "2.0"
11        pub method: &'a str,  // A String containing the name of the method to be invoked.
12        #[serde(skip_serializing_if = "Option::is_none")]
13        pub id: Option<I>, // An identifier established by the Client that MUST contain a String, Number, or NULL value if included.
14        #[serde(skip_serializing_if = "Option::is_none")]
15        pub params: Option<S>, // A Structured value that holds the parameter values to be used during the invocation of the method.
16    }
17
18    #[derive(serde::Deserialize, Debug, Clone)]
19    pub struct Error {
20        pub code: i64,
21        pub message: String,
22    }
23
24    #[derive(serde::Deserialize)]
25    #[serde(untagged)]
26    pub enum Response<I, R, N> {
27        Resp { id: I, result: R },
28        Notification { method: String, params: N },
29        Err { id: I, error: Error },
30    }
31}
32
33
34pub use error::Error;
35pub use ws::{Client, ConnectionMeta, Notification};
36
37pub type Result<T> = std::result::Result<T, Error>;
38