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/src/client/mod.rs | 5 ++++- jsonrpc/src/lib.rs | 2 +- jsonrpc/src/message.rs | 4 ++-- jsonrpc/src/server/channel.rs | 3 +-- 4 files changed, 8 insertions(+), 6 deletions(-) (limited to 'jsonrpc/src') 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