diff --git a/rpc/types/src/data/access_request_base.rs b/rpc/types/src/data/access_request_base.rs new file mode 100644 index 0000000..95714c0 --- /dev/null +++ b/rpc/types/src/data/access_request_base.rs @@ -0,0 +1,24 @@ +//! TODO + +//---------------------------------------------------------------------------------------------------- Import +use serde::{Deserialize, Serialize}; + +use crate::Status; + +//---------------------------------------------------------------------------------------------------- ResponseBase +/// TODO +/// +/// . +#[derive( + Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, +)] +pub struct AccessRequestBase { + /// TODO + client: String, +} + +//---------------------------------------------------------------------------------------------------- Tests +#[cfg(test)] +mod test { + // use super::*; +} diff --git a/rpc/types/src/data/access_response_base.rs b/rpc/types/src/data/access_response_base.rs new file mode 100644 index 0000000..0c40d20 --- /dev/null +++ b/rpc/types/src/data/access_response_base.rs @@ -0,0 +1,27 @@ +//! TODO + +//---------------------------------------------------------------------------------------------------- Import +use serde::{Deserialize, Serialize}; + +use crate::data::ResponseBase; + +//---------------------------------------------------------------------------------------------------- ResponseBase +/// TODO +/// +/// . +#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] +pub struct AccessResponseBase { + /// TODO + #[serde(flatten)] + response_base: ResponseBase, + /// TODO + credits: u64, + /// TODO + top_hash: String, +} + +//---------------------------------------------------------------------------------------------------- Tests +#[cfg(test)] +mod test { + // use super::*; +} diff --git a/rpc/types/src/data/mod.rs b/rpc/types/src/data/mod.rs index 5577a7a..55db915 100644 --- a/rpc/types/src/data/mod.rs +++ b/rpc/types/src/data/mod.rs @@ -2,8 +2,10 @@ //! //! TODO +mod access_response_base; mod binary_string; mod response_base; +pub use access_response_base::AccessResponseBase; pub use binary_string::BinaryString; pub use response_base::ResponseBase; diff --git a/rpc/types/src/data/response_base.rs b/rpc/types/src/data/response_base.rs index e23c6e1..31160d6 100644 --- a/rpc/types/src/data/response_base.rs +++ b/rpc/types/src/data/response_base.rs @@ -1,10 +1,17 @@ //! TODO //---------------------------------------------------------------------------------------------------- Import +use serde::{Deserialize, Serialize}; + use crate::Status; //---------------------------------------------------------------------------------------------------- ResponseBase /// TODO +/// +/// . +#[derive( + Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, +)] pub struct ResponseBase { /// TODO status: Status, diff --git a/rpc/types/src/status.rs b/rpc/types/src/status.rs index 8ff6877..e869ac1 100644 --- a/rpc/types/src/status.rs +++ b/rpc/types/src/status.rs @@ -60,10 +60,12 @@ use crate::constants::{ /// assert_eq!(format!("{:?}", Status::PaymentRequired), "PaymentRequired"); /// assert_eq!(format!("{:?}", other), "Other(\"hello\")"); /// ``` -#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] +#[derive( + Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, +)] pub enum Status { // FIXME: - // `#[serde(rename = "")]` onlys takes raw string literals? + // `#[serde(rename = "")]` only takes raw string literals? // We have to re-type the constants here... /// Successful RPC response, everything is OK; [`CORE_RPC_STATUS_OK`]. #[serde(rename = "OK")] @@ -82,12 +84,12 @@ pub enum Status { #[serde(rename = "PAYMENT REQUIRED")] PaymentRequired, - #[serde(untagged)] + #[serde(other)] /// Some unknown other string. /// /// This exists to act as a catch-all if `monerod` adds /// a string and a Cuprate node hasn't updated yet. - Other(String), + Unknown, } impl From for Status { @@ -97,7 +99,7 @@ impl From for Status { CORE_RPC_STATUS_BUSY => Self::Busy, CORE_RPC_STATUS_NOT_MINING => Self::NotMining, CORE_RPC_STATUS_PAYMENT_REQUIRED => Self::PaymentRequired, - _ => Self::Other(s), + _ => Self::Unknown, } } } @@ -109,7 +111,7 @@ impl AsRef for Status { Self::Busy => CORE_RPC_STATUS_BUSY, Self::NotMining => CORE_RPC_STATUS_NOT_MINING, Self::PaymentRequired => CORE_RPC_STATUS_PAYMENT_REQUIRED, - Self::Other(s) => s, + Self::Unknown => "UNKNOWN", } } } @@ -135,10 +137,7 @@ impl EpeeValue for Status { } fn should_write(&self) -> bool { - match self { - Self::Ok | Self::Busy | Self::NotMining | Self::PaymentRequired => true, - Self::Other(s) => !s.is_empty(), - } + true } fn epee_default_value() -> Option {