From 8779a0e714367e7c3b576e39c753f85a45514bf3 Mon Sep 17 00:00:00 2001 From: hozan23 Date: Mon, 20 Nov 2023 23:25:29 +0300 Subject: jsonrpc/codec: rename `max_allowed_msg_size` to `max_allowed_buffer_size` --- jsonrpc/src/client.rs | 4 ++-- jsonrpc/src/codec.rs | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/jsonrpc/src/client.rs b/jsonrpc/src/client.rs index d5caebe..1ce9ecb 100644 --- a/jsonrpc/src/client.rs +++ b/jsonrpc/src/client.rs @@ -25,7 +25,7 @@ impl Client { /// Creates a new RPC client. pub fn new(conn: Conn, config: ClientConfig) -> Self { let codec_config = CodecConfig { - max_allowed_msg_size: 0, + max_allowed_buffer_size: 0, ..Default::default() }; let codec = Codec::new(conn, codec_config); @@ -36,7 +36,7 @@ impl Client { pub async fn new_with_endpoint(endpoint: &Endpoint, config: ClientConfig) -> Result { let conn = dial(endpoint).await?; let codec_config = CodecConfig { - max_allowed_msg_size: 0, + max_allowed_buffer_size: 0, ..Default::default() }; let codec = Codec::new(conn, codec_config); diff --git a/jsonrpc/src/codec.rs b/jsonrpc/src/codec.rs index ea97e54..41fed06 100644 --- a/jsonrpc/src/codec.rs +++ b/jsonrpc/src/codec.rs @@ -6,7 +6,7 @@ use karyons_net::Conn; use crate::{Error, Result}; const DEFAULT_BUFFER_SIZE: usize = 1024; -const DEFAULT_MAX_ALLOWED_MSG_SIZE: usize = 1024 * 1024; // 1MB +const DEFAULT_MAX_ALLOWED_BUFFER_SIZE: usize = 1024 * 1024; // 1MB // TODO: Add unit tests for Codec's functions. @@ -14,16 +14,16 @@ const DEFAULT_MAX_ALLOWED_MSG_SIZE: usize = 1024 * 1024; // 1MB #[derive(Clone)] pub struct CodecConfig { pub default_buffer_size: usize, - /// The maximum allowed size to receive a message. If set to zero, there - /// will be no size limit. - pub max_allowed_msg_size: usize, + /// The maximum allowed buffer size to receive a message. If set to zero, + /// there will be no size limit. + pub max_allowed_buffer_size: usize, } impl Default for CodecConfig { fn default() -> Self { Self { default_buffer_size: DEFAULT_BUFFER_SIZE, - max_allowed_msg_size: DEFAULT_MAX_ALLOWED_MSG_SIZE, + max_allowed_buffer_size: DEFAULT_MAX_ALLOWED_BUFFER_SIZE, } } } @@ -67,8 +67,8 @@ impl Codec { } } - if self.config.max_allowed_msg_size != 0 - && buffer.len() == self.config.max_allowed_msg_size + if self.config.max_allowed_buffer_size != 0 + && buffer.len() == self.config.max_allowed_buffer_size { return Err(Error::InvalidMsg( "Message exceeds the maximum allowed size", -- cgit v1.2.3