Skip to main content

Module handler

Module handler 

Source
Expand description

Handler module - request handling and dispatch.

Provides:

§Example

use procwire_client::handler::{HandlerRegistry, RequestContext};
use procwire_client::control::ResponseType;

let mut registry = HandlerRegistry::new();

// Register a method handler
registry.register("echo", ResponseType::Result, |data: String, ctx| async move {
    ctx.respond(&data).await
});

// Register a streaming handler
registry.register("count", ResponseType::Stream, |n: i32, ctx| async move {
    for i in 0..n {
        ctx.chunk(&i).await?;
    }
    ctx.end().await
});

Structs§

HandlerRegistry
Registry mapping method names to handlers.
RawPayload
Wrapper for Bytes payload (zero-copy).
RequestContext
Context passed to request handlers.
TypedHandler
Wrapper that deserializes payload before calling the handler.

Traits§

Handler
Trait for handler functions.

Type Aliases§

BoxFuture
Boxed future for handler results.
HandlerResult
Result type for handler functions.