Skip to main content

ServiceHandler

Trait ServiceHandler 

Source
pub trait ServiceHandler: MaybeSendSync + 'static {
    type Workload: Workload;
}
Expand description

Associator trait emitted by protoc-gen: maps a user-implemented handler type to the generated {Service}Workload<Self> wrapper.

Users never implement this trait by hand; the generator’s {Service}Handler trait expands into a super-trait bound on it so the framework can recover type Workload without name mangling.

§Design notes

  • MaybeSendSync + 'static mirrors the bound on every {Service}Handler, so downstream generic code can compose ServiceHandler bounds into dispatcher-generic functions without re-stating the auto-trait marker.
  • The associated type pins a concrete Workload impl, not a dyn Workload. Static dispatch all the way down — matching the rest of the framework’s zero-cost abstractions.

Required Associated Types§

Source

type Workload: Workload

Concrete Workload wrapper for this handler.

protoc-gen’s {Service}Handler trait sets this to the generated {Service}Workload<Self> wrapper, which carries the dispatcher (via type Dispatcher = {Service}Dispatcher<Self>) and inherits every observation-hook default from Workload.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§