Skip to main content

ApiModule

Trait ApiModule 

Source
pub trait ApiModule: Send + Sync {
    // Required methods
    fn prefixes(&self) -> &[&str];
    fn handle(&self, request: &Request<'_>) -> Result<Value, String>;

    // Provided method
    fn start(&self, _host: &dyn TaskHost) -> Result<(), String> { ... }
}
Expand description

A host module: owns every request type that starts with one of its prefixes.

Required Methods§

Source

fn prefixes(&self) -> &[&str]

Source

fn handle(&self, request: &Request<'_>) -> Result<Value, String>

Provided Methods§

Source

fn start(&self, _host: &dyn TaskHost) -> Result<(), String>

Called once before the first request is served.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§