#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum Rpc {
GetBestBlockHash,
GetBlock,
GetBlockCount,
GetBlockFilter,
GetBlockHash,
GetBlockHeader,
GetRawMempool,
GetRawTransaction,
GetBlockchainInfo,
SendRawTransaction,
}
impl core::fmt::Display for Rpc {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let s = match self {
Self::GetBestBlockHash => "getbestblockhash",
Self::GetBlock => "getblock",
Self::GetBlockCount => "getblockcount",
Self::GetBlockFilter => "getblockfilter",
Self::GetBlockHash => "getblockhash",
Self::GetBlockHeader => "getblockheader",
Self::GetRawMempool => "getrawmempool",
Self::GetRawTransaction => "getrawtransaction",
Self::GetBlockchainInfo => "getblockchaininfo",
Self::SendRawTransaction => "sendrawtransaction",
};
write!(f, "{s}")
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn rpc_display_lowercase() {
assert_eq!(Rpc::GetBestBlockHash.to_string(), "getbestblockhash");
assert_eq!(Rpc::GetBlock.to_string(), "getblock");
assert_eq!(Rpc::GetBlockCount.to_string(), "getblockcount");
assert_eq!(Rpc::GetBlockFilter.to_string(), "getblockfilter");
assert_eq!(Rpc::GetBlockHash.to_string(), "getblockhash");
assert_eq!(Rpc::GetBlockHeader.to_string(), "getblockheader");
assert_eq!(Rpc::GetRawMempool.to_string(), "getrawmempool");
assert_eq!(Rpc::GetRawTransaction.to_string(), "getrawtransaction");
assert_eq!(Rpc::SendRawTransaction.to_string(), "sendrawtransaction");
assert_eq!(Rpc::GetBlockchainInfo.to_string(), "getblockchaininfo");
}
}