From 587a1bfdcbdfaf2ea7ec646082bcd008b817381b Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Sat, 11 Jan 2025 14:45:16 +0100 Subject: [PATCH 1/2] feat(rpc): setters for `TransportRpcModules` --- crates/rpc/rpc-builder/src/lib.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/crates/rpc/rpc-builder/src/lib.rs b/crates/rpc/rpc-builder/src/lib.rs index 1e758522e486..67f9ce7fe08c 100644 --- a/crates/rpc/rpc-builder/src/lib.rs +++ b/crates/rpc/rpc-builder/src/lib.rs @@ -2110,6 +2110,30 @@ pub struct TransportRpcModules { // === impl TransportRpcModules === impl TransportRpcModules { + /// Sets a custom [`TransportRpcModuleConfig`] for the configured modules. + pub fn with_config(mut self, config: TransportRpcModuleConfig) -> Self { + self.config = config; + self + } + + /// Sets the [`RpcModule`] for the http transport. + pub fn with_http(mut self, http: RpcModule<()>) -> Self { + self.http = Some(http); + self + } + + /// Sets the [`RpcModule`] for the ws transport. + pub fn with_ws(mut self, ws: RpcModule<()>) -> Self { + self.ws = Some(ws); + self + } + + /// Sets the [`RpcModule`] for the http transport. + pub fn with_ipc(mut self, ipc: RpcModule<()>) -> Self { + self.ipc = Some(ipc); + self + } + /// Returns the [`TransportRpcModuleConfig`] used to configure this instance. pub const fn module_config(&self) -> &TransportRpcModuleConfig { &self.config From d1c429d3d2e4d12419a263b1fa628f203549838d Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Sat, 11 Jan 2025 16:22:54 +0100 Subject: [PATCH 2/2] docs --- crates/rpc/rpc-builder/src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/rpc/rpc-builder/src/lib.rs b/crates/rpc/rpc-builder/src/lib.rs index 67f9ce7fe08c..e852c39f8fc6 100644 --- a/crates/rpc/rpc-builder/src/lib.rs +++ b/crates/rpc/rpc-builder/src/lib.rs @@ -2111,24 +2111,28 @@ pub struct TransportRpcModules { impl TransportRpcModules { /// Sets a custom [`TransportRpcModuleConfig`] for the configured modules. + /// This will overwrite current configuration, if any. pub fn with_config(mut self, config: TransportRpcModuleConfig) -> Self { self.config = config; self } /// Sets the [`RpcModule`] for the http transport. + /// This will overwrite current module, if any. pub fn with_http(mut self, http: RpcModule<()>) -> Self { self.http = Some(http); self } /// Sets the [`RpcModule`] for the ws transport. + /// This will overwrite current module, if any. pub fn with_ws(mut self, ws: RpcModule<()>) -> Self { self.ws = Some(ws); self } /// Sets the [`RpcModule`] for the http transport. + /// This will overwrite current module, if any. pub fn with_ipc(mut self, ipc: RpcModule<()>) -> Self { self.ipc = Some(ipc); self