Skip to content

Commit 036626b

Browse files
authored
docs: improve map_add_ons method documentation (#20248)
1 parent 68f0c98 commit 036626b

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

crates/node/builder/src/builder/mod.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,27 @@ where
533533
}
534534

535535
/// Modifies the addons with the given closure.
536+
///
537+
/// This method provides access to methods on the addons type that don't have
538+
/// direct builder methods. It's useful for advanced configuration scenarios
539+
/// where you need to call addon-specific methods.
540+
///
541+
/// # Examples
542+
///
543+
/// ```rust,ignore
544+
/// use tower::layer::util::Identity;
545+
///
546+
/// let builder = NodeBuilder::new(config)
547+
/// .with_types::<EthereumNode>()
548+
/// .with_components(EthereumNode::components())
549+
/// .with_add_ons(EthereumAddOns::default())
550+
/// .map_add_ons(|addons| addons.with_rpc_middleware(Identity::default()));
551+
/// ```
552+
///
553+
/// # See also
554+
///
555+
/// - [`NodeAddOns`] trait for available addon types
556+
/// - [`crate::NodeBuilderWithComponents::extend_rpc_modules`] for RPC module configuration
536557
pub fn map_add_ons<F>(self, f: F) -> Self
537558
where
538559
F: FnOnce(AO) -> AO,
@@ -579,10 +600,10 @@ where
579600
/// .extend_rpc_modules(|ctx| {
580601
/// // Access node components, so they can used by the CustomApi
581602
/// let pool = ctx.pool().clone();
582-
///
603+
///
583604
/// // Add custom RPC namespace
584605
/// ctx.modules.merge_configured(CustomApi { pool }.into_rpc())?;
585-
///
606+
///
586607
/// Ok(())
587608
/// })
588609
/// .build()?;

crates/node/builder/src/builder/states.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,27 @@ where
235235
}
236236

237237
/// Modifies the addons with the given closure.
238+
///
239+
/// This method provides access to methods on the addons type that don't have
240+
/// direct builder methods. It's useful for advanced configuration scenarios
241+
/// where you need to call addon-specific methods.
242+
///
243+
/// # Examples
244+
///
245+
/// ```rust,ignore
246+
/// use tower::layer::util::Identity;
247+
///
248+
/// let builder = NodeBuilder::new(config)
249+
/// .with_types::<EthereumNode>()
250+
/// .with_components(EthereumNode::components())
251+
/// .with_add_ons(EthereumAddOns::default())
252+
/// .map_add_ons(|addons| addons.with_rpc_middleware(Identity::default()));
253+
/// ```
254+
///
255+
/// # See also
256+
///
257+
/// - [`NodeAddOns`] trait for available addon types
258+
/// - [`crate::NodeBuilderWithComponents::extend_rpc_modules`] for RPC module configuration
238259
pub fn map_add_ons<F>(mut self, f: F) -> Self
239260
where
240261
F: FnOnce(AO) -> AO,

0 commit comments

Comments
 (0)