Skip to content

Commit

Permalink
rpc: remove method
Browse files Browse the repository at this point in the history
  • Loading branch information
polachok committed Jun 21, 2024
1 parent 60c4fed commit 53a0a6c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/src/server/rpc_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ impl Methods {
}
}

// Removes the method callback for a given name, if it exists.
fn remove(&mut self, name: &'static str) -> Option<MethodCallback> {
self.mut_callbacks().remove(name)
}

/// Helper for obtaining a mut ref to the callbacks HashMap.
fn mut_callbacks(&mut self) -> &mut FxHashMap<&'static str, MethodCallback> {
Arc::make_mut(&mut self.callbacks)
Expand Down Expand Up @@ -552,6 +557,11 @@ impl<Context: Send + Sync + 'static> RpcModule<Context> {
)
}

/// Removes method if it exists.
pub fn remove_method(&mut self, method_name: &'static str) -> Option<MethodCallback> {
self.methods.remove(method_name)
}

/// Register a new asynchronous RPC method, which computes the response with the given callback.
///
/// ## Examples
Expand Down

0 comments on commit 53a0a6c

Please sign in to comment.