Skip to main content

ServiceExt

Trait ServiceExt 

Source
pub trait ServiceExt: Service {
    // Required method
    fn register(self: Arc<Self>, router: Router) -> Router;
}
Expand description

Extension trait for registering a service implementation with a Router.

This trait is automatically implemented for all types that implement the service trait.

§Example

use std::sync::Arc;

let service = Arc::new(MyServiceImpl);
let router = service.register(Router::new());

Required Methods§

Source

fn register(self: Arc<Self>, router: Router) -> Router

Register this service implementation with a Router.

Takes ownership of the Arc<Self> and returns a new Router with this service’s methods registered.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§