Trait ResponseFactory

Source
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§

Source

fn success<T: Serialize>(&self, data: T) -> impl IntoResponse

Creates a success response

Source

fn error(&self, message: &str, status: StatusCode) -> impl IntoResponse

Creates an error response

Source

fn paginated<T: Serialize>( &self, data: Vec<T>, total: u64, page: u64, per_page: u64, ) -> impl IntoResponse

Creates a paginated 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.

Implementors§