aboutsummaryrefslogtreecommitdiff
path: root/jsonrpc/src/server/pubsub_service.rs
diff options
context:
space:
mode:
authorhozan23 <hozan23@karyontech.net>2024-06-30 20:03:02 +0200
committerhozan23 <hozan23@karyontech.net>2024-06-30 20:03:02 +0200
commit3c55168b72c022b618822c7993b7692f583506db (patch)
tree146c03f6cc19956ec0acfb7ba26a6202cb5a9647 /jsonrpc/src/server/pubsub_service.rs
parent2ec4d4a3c3779dc016c8437891f825a54a805808 (diff)
jsonrpc: remove redundant macro codes in the main crate and clean up
internal proc macros
Diffstat (limited to 'jsonrpc/src/server/pubsub_service.rs')
-rw-r--r--jsonrpc/src/server/pubsub_service.rs53
1 files changed, 0 insertions, 53 deletions
diff --git a/jsonrpc/src/server/pubsub_service.rs b/jsonrpc/src/server/pubsub_service.rs
index a6b4c11..909b0b0 100644
--- a/jsonrpc/src/server/pubsub_service.rs
+++ b/jsonrpc/src/server/pubsub_service.rs
@@ -15,56 +15,3 @@ pub trait PubSubRPCService: Sync + Send {
fn get_pubsub_method<'a>(&'a self, name: &'a str) -> Option<PubSubRPCMethod>;
fn name(&self) -> String;
}
-
-/// Implements the [`PubSubRPCService`] trait for a provided type.
-///
-/// # Example
-///
-/// ```
-/// use serde_json::Value;
-///
-/// use karyon_jsonrpc::{RPCError, impl_rpc_service};
-///
-/// struct Hello {}
-///
-/// impl Hello {
-/// async fn foo(&self, params: Value) -> Result<Value, RPCError> {
-/// Ok(serde_json::json!("foo!"))
-/// }
-///
-/// async fn bar(&self, params: Value) -> Result<Value, RPCError> {
-/// Ok(serde_json::json!("bar!"))
-/// }
-/// }
-///
-/// impl_rpc_service!(Hello, foo, bar);
-///
-/// ```
-#[macro_export]
-macro_rules! impl_pubsub_rpc_service {
- ($t:ty, $($m:ident),*) => {
- impl karyon_jsonrpc::PubSubRPCService for $t {
- fn get_pubsub_method<'a>(
- &'a self,
- name: &'a str
- ) -> Option<karyon_jsonrpc::PubSubRPCMethod> {
- match name {
- $(
- stringify!($m) => {
- Some(Box::new(
- move |chan: std::sync::Arc<karyon_jsonrpc::Channel>, method: String, params: serde_json::Value| {
- Box::pin(self.$m(chan, method, params))
- }))
- }
- )*
- _ => None,
- }
-
-
- }
- fn name(&self) -> String{
- stringify!($t).to_string()
- }
- }
- };
-}