pub trait WsMethod:
Send
+ Sync
+ 'static {
type Params: DeserializeOwned + Send;
const METHOD: &'static str;
const IS_STREAMING: bool = false;
// Required method
fn handle<'async_trait>(
ctx: Arc<WsContext>,
req: WsRequest,
params: Self::Params,
sink: WsOpSink,
) -> Pin<Box<dyn Future<Output = WsResult<()>> + Send + 'async_trait>>
where Self: 'async_trait;
// Provided method
fn validate(_params: &Self::Params) -> WsResult<()> { ... }
}Expand description
Trait for WebSocket method handlers
Each method handler implements this trait to define:
- The method name (e.g., “rpki.validate”)
- Whether it’s a streaming method
- How to parse and validate parameters
- How to execute the method
Required Associated Constants§
Provided Associated Constants§
Sourceconst IS_STREAMING: bool = false
const IS_STREAMING: bool = false
Whether this method is streaming (returns progress/stream messages)
Required Associated Types§
Sourcetype Params: DeserializeOwned + Send
type Params: DeserializeOwned + Send
Parameter type for this method
Required Methods§
Sourcefn handle<'async_trait>(
ctx: Arc<WsContext>,
req: WsRequest,
params: Self::Params,
sink: WsOpSink,
) -> Pin<Box<dyn Future<Output = WsResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
fn handle<'async_trait>(
ctx: Arc<WsContext>,
req: WsRequest,
params: Self::Params,
sink: WsOpSink,
) -> Pin<Box<dyn Future<Output = WsResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
Execute the method
For non-streaming methods, this should send a single result via the sink. For streaming methods, this may send progress/stream messages followed by a result.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.