pub trait ResponseFactory: Send + Sync {
// Required methods
fn success<T: Serialize>(&self, data: T) -> impl IntoResponse;
fn error(&self, message: &str, status: StatusCode) -> impl IntoResponse;
fn paginated<T: Serialize>(
&self,
data: Vec<T>,
total: u64,
page: u64,
per_page: u64,
) -> impl IntoResponse;
}
Expand description
Trait for HTTP response factories
Required Methods§
Sourcefn success<T: Serialize>(&self, data: T) -> impl IntoResponse
fn success<T: Serialize>(&self, data: T) -> impl IntoResponse
Creates a success response
Sourcefn error(&self, message: &str, status: StatusCode) -> impl IntoResponse
fn error(&self, message: &str, status: StatusCode) -> impl IntoResponse
Creates an error response
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.