Skip to content

Commit

Permalink
feat: RpcModule::from_arc (#1324)
Browse files Browse the repository at this point in the history
* feat: RpcModule::context

* feat: RpcModule::from_arc
  • Loading branch information
aatifsyed authored and niklasad1 committed Mar 20, 2024
1 parent 2f16e78 commit bbba86d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/src/server/rpc_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,14 @@ pub struct RpcModule<Context> {
impl<Context> RpcModule<Context> {
/// Create a new module with a given shared `Context`.
pub fn new(ctx: Context) -> Self {
Self { ctx: Arc::new(ctx), methods: Default::default() }
Self::from_arc(Arc::new(ctx))
}

/// Create a new module from an already shared `Context`.
///
/// This is useful if `Context` needs to be shared outside of an [`RpcModule`].
pub fn from_arc(ctx: Arc<Context>) -> Self {
Self { ctx, methods: Default::default() }
}

/// Transform a module into an `RpcModule<()>` (unit context).
Expand Down

0 comments on commit bbba86d

Please sign in to comment.