pub trait ControllerSpec {
// Required method
fn kind() -> Controller;
}Expand description
A trait for defining controllers in the application.
Controllers represent different entry points into your application. automatically implement this trait, allowing them to be registered as HTTP controllers within modules.
§Example
ⓘ
use sword::prelude::*;
#[controller(kind = Controller::Web, path = "/api/items")]
struct ItemsController { /* ... */ }
// The macro automatically implements ControllerSpec for ItemsController
// In your module:
fn register_controllers(controllers: &ControllerRegistry) {
controllers.register::<ItemsController>();
}Required Methods§
fn kind() -> Controller
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".