MethodRegistry

Struct MethodRegistry 

Source
pub struct MethodRegistry { /* private fields */ }
Expand description

Registry for organizing and dispatching JSON-RPC methods

Implementations§

Source§

impl MethodRegistry

Source

pub fn new() -> Self

Create a new empty method registry

Source

pub fn register<F>(self, method: impl Into<String>, handler: F) -> Self
where F: Fn(Option<Value>, Option<RequestId>) -> Response + Send + Sync + 'static,

Register a method with a handler function

Source

pub fn register_with_info<F>( self, method: impl Into<String>, info: MethodInfo, handler: F, ) -> Self
where F: Fn(Option<Value>, Option<RequestId>) -> Response + Send + Sync + 'static,

Register a method with detailed information and handler

Source

pub fn call( &self, method: &str, params: Option<Value>, id: Option<RequestId>, ) -> Response

Call a registered method

Source

pub fn has_method(&self, method: &str) -> bool

Check if a method is registered

Source

pub fn get_methods(&self) -> Vec<String>

Get list of all registered methods

Source

pub fn method_count(&self) -> usize

Get the number of registered methods

Source

pub fn remove_method(&mut self, method: &str) -> bool

Remove a method from the registry

Source

pub fn clear(&mut self)

Clear all methods from the registry

Source

pub fn render_docs(&mut self) -> Value

Generate a Swagger/OpenAPI JSON object describing all registered methods Results are cached until the registry is modified

Trait Implementations§

Source§

impl Default for MethodRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Handler for MethodRegistry

Source§

fn handle_request(&self, request: Request) -> Response

Handle a JSON-RPC request and return a response
Source§

fn handle_notification(&self, notification: Notification)

Handle a JSON-RPC notification (no response expected)
Source§

fn supports_method(&self, method: &str) -> bool

Check if a method is supported
Source§

fn get_supported_methods(&self) -> Vec<String>

Get list of supported methods
Source§

fn get_method_info(&self, method: &str) -> Option<MethodInfo>

Get method information for documentation
Source§

impl MessageProcessor for MethodRegistry

Source§

fn process_message(&self, message: Message) -> Option<Response>

Process a single JSON-RPC message
Source§

fn get_capabilities(&self) -> ProcessorCapabilities

Get processor capabilities
Source§

fn process_batch(&self, messages: Vec<Message>) -> Vec<Response>

Process a batch of JSON-RPC messages
Source§

fn supports_batching(&self) -> bool

Check if batch processing is supported

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.