From 9341e695d0e387927804716b60945912cba686dd Mon Sep 17 00:00:00 2001 From: hozan23 Date: Tue, 28 May 2024 00:26:59 +0200 Subject: jsonrpc: move `SubscriptionID` to message.rs --- jsonrpc/README.md | 3 ++- jsonrpc/examples/pubsub_server.rs | 4 +++- jsonrpc/src/client/mod.rs | 5 ++++- jsonrpc/src/lib.rs | 2 +- jsonrpc/src/message.rs | 4 ++-- jsonrpc/src/server/channel.rs | 3 +-- 6 files changed, 13 insertions(+), 8 deletions(-) (limited to 'jsonrpc') diff --git a/jsonrpc/README.md b/jsonrpc/README.md index 03f5ace..5fc6847 100644 --- a/jsonrpc/README.md +++ b/jsonrpc/README.md @@ -22,7 +22,8 @@ use serde_json::Value; use smol::stream::StreamExt; use karyon_jsonrpc::{ - Error, Server, Client, rpc_impl, rpc_pubsub_impl, SubscriptionID, ArcChannel + Error, Server, Client, rpc_impl, rpc_pubsub_impl, message::SubscriptionID, + ArcChannel }; struct HelloWorld {} diff --git a/jsonrpc/examples/pubsub_server.rs b/jsonrpc/examples/pubsub_server.rs index 4b77c45..bae5b37 100644 --- a/jsonrpc/examples/pubsub_server.rs +++ b/jsonrpc/examples/pubsub_server.rs @@ -4,7 +4,9 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; use karyon_core::async_util::sleep; -use karyon_jsonrpc::{rpc_impl, rpc_pubsub_impl, ArcChannel, Error, Server, SubscriptionID}; +use karyon_jsonrpc::{ + message::SubscriptionID, rpc_impl, rpc_pubsub_impl, ArcChannel, Error, Server, +}; struct Calc {} diff --git a/jsonrpc/src/client/mod.rs b/jsonrpc/src/client/mod.rs index 0666ee0..05479f9 100644 --- a/jsonrpc/src/client/mod.rs +++ b/jsonrpc/src/client/mod.rs @@ -13,7 +13,10 @@ use karyon_core::{ }; use karyon_net::Conn; -use crate::{message, Error, Result, SubscriptionID}; +use crate::{ + message::{self, SubscriptionID}, + Error, Result, +}; const CHANNEL_CAP: usize = 10; diff --git a/jsonrpc/src/lib.rs b/jsonrpc/src/lib.rs index 14840fa..b7b632e 100644 --- a/jsonrpc/src/lib.rs +++ b/jsonrpc/src/lib.rs @@ -10,7 +10,7 @@ pub use client::{builder::ClientBuilder, Client}; pub use error::{Error, Result}; pub use server::{ builder::ServerBuilder, - channel::{ArcChannel, Channel, Subscription, SubscriptionID}, + channel::{ArcChannel, Channel, Subscription}, pubsub_service::{PubSubRPCMethod, PubSubRPCService}, service::{RPCMethod, RPCService}, Server, diff --git a/jsonrpc/src/message.rs b/jsonrpc/src/message.rs index 34d6235..1f296cd 100644 --- a/jsonrpc/src/message.rs +++ b/jsonrpc/src/message.rs @@ -1,7 +1,5 @@ use serde::{Deserialize, Serialize}; -use crate::SubscriptionID; - pub type ID = u64; pub const JSONRPC_VERSION: &str = "2.0"; @@ -21,6 +19,8 @@ pub const INVALID_PARAMS_ERROR_CODE: i32 = -32602; /// Internal error: Internal JSON-RPC error. pub const INTERNAL_ERROR_CODE: i32 = -32603; +pub type SubscriptionID = u32; + #[derive(Debug, Serialize, Deserialize)] pub struct Request { pub jsonrpc: String, diff --git a/jsonrpc/src/server/channel.rs b/jsonrpc/src/server/channel.rs index f14c1dd..efcd344 100644 --- a/jsonrpc/src/server/channel.rs +++ b/jsonrpc/src/server/channel.rs @@ -2,9 +2,8 @@ use std::sync::Arc; use karyon_core::{async_runtime::lock::Mutex, util::random_32}; -use crate::{Error, Result}; +use crate::{message::SubscriptionID, Error, Result}; -pub type SubscriptionID = u32; pub type ArcChannel = Arc; pub(crate) struct NewNotification { -- cgit v1.2.3