WsMethod

Trait WsMethod 

Source
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§

Source

const METHOD: &'static str

Fully qualified method name, e.g., “rpki.validate”

Provided Associated Constants§

Source

const IS_STREAMING: bool = false

Whether this method is streaming (returns progress/stream messages)

Required Associated Types§

Source

type Params: DeserializeOwned + Send

Parameter type for this method

Required Methods§

Source

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§

Source

fn validate(_params: &Self::Params) -> WsResult<()>

Validate parameters after parsing

Override this to perform additional validation beyond JSON deserialization.

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.

Implementors§

Source§

impl WsMethod for As2relRelationshipHandler

Source§

const METHOD: &'static str = "as2rel.relationship"

Source§

const IS_STREAMING: bool = false

Source§

type Params = As2relRelationshipParams

Source§

impl WsMethod for As2relSearchHandler

Source§

const METHOD: &'static str = "as2rel.search"

Source§

const IS_STREAMING: bool = false

Source§

type Params = As2relSearchParams

Source§

impl WsMethod for As2relUpdateHandler

Source§

const METHOD: &'static str = "as2rel.update"

Source§

const IS_STREAMING: bool = false

Source§

type Params = As2relUpdateParams

Source§

impl WsMethod for CountryLookupHandler

Source§

const METHOD: &'static str = "country.lookup"

Source§

const IS_STREAMING: bool = false

Source§

type Params = CountryLookupParams

Source§

impl WsMethod for DatabaseRefreshHandler

Source§

const METHOD: &'static str = "database.refresh"

Source§

const IS_STREAMING: bool = false

Source§

type Params = DatabaseRefreshParams

Source§

impl WsMethod for DatabaseStatusHandler

Source§

const METHOD: &'static str = "database.status"

Source§

const IS_STREAMING: bool = false

Source§

type Params = DatabaseStatusParams

Source§

impl WsMethod for InspectQueryHandler

Source§

const METHOD: &'static str = "inspect.query"

Source§

const IS_STREAMING: bool = true

Source§

type Params = InspectQueryParams

Source§

impl WsMethod for InspectRefreshHandler

Source§

const METHOD: &'static str = "inspect.refresh"

Source§

const IS_STREAMING: bool = true

Source§

type Params = InspectRefreshParams

Source§

impl WsMethod for IpLookupHandler

Source§

const METHOD: &'static str = "ip.lookup"

Source§

const IS_STREAMING: bool = false

Source§

type Params = IpLookupParams

Source§

impl WsMethod for IpPublicHandler

Source§

const METHOD: &'static str = "ip.public"

Source§

const IS_STREAMING: bool = false

Source§

type Params = IpPublicParams

Source§

impl WsMethod for Pfx2asLookupHandler

Source§

const METHOD: &'static str = "pfx2as.lookup"

Source§

const IS_STREAMING: bool = false

Source§

type Params = Pfx2asLookupParams

Source§

impl WsMethod for RpkiAspasHandler

Source§

const METHOD: &'static str = "rpki.aspas"

Source§

const IS_STREAMING: bool = false

Source§

type Params = RpkiAspasParams

Source§

impl WsMethod for RpkiRoasHandler

Source§

const METHOD: &'static str = "rpki.roas"

Source§

const IS_STREAMING: bool = false

Source§

type Params = RpkiRoasParams

Source§

impl WsMethod for RpkiValidateHandler

Source§

const METHOD: &'static str = "rpki.validate"

Source§

const IS_STREAMING: bool = false

Source§

type Params = RpkiValidateParams

Source§

impl WsMethod for SystemInfoHandler

Source§

const METHOD: &'static str = "system.info"

Source§

const IS_STREAMING: bool = false

Source§

type Params = SystemInfoParams

Source§

impl WsMethod for TimeParseHandler

Source§

const METHOD: &'static str = "time.parse"

Source§

const IS_STREAMING: bool = false

Source§

type Params = TimeParseParams