Skip to main content

WorkerProtocolHandler

Trait WorkerProtocolHandler 

Source
pub trait WorkerProtocolHandler {
    // Provided method
    fn dispatch(
        &self,
        opcode: &WorkerOpcode,
        body: &[u8],
    ) -> Result<Vec<u8>, String> { ... }
}
Expand description

Abstract handler for the worker protocol’s server side. Each opcode dispatches to a corresponding method here; the default implementation returns a typed unhandled-opcode error so an incomplete handler surfaces missing opcodes loudly.

In production, sui-daemon implements this trait against its real store. Tests can provide a mock that records dispatched opcodes for verification.

Provided Methods§

Source

fn dispatch( &self, opcode: &WorkerOpcode, body: &[u8], ) -> Result<Vec<u8>, String>

Catch-all handler. Default returns unhandled-opcode error. Concrete impls override per opcode they support.

§Errors

Default impl always. Concrete handlers return per-opcode errors.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§