use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize)] pub struct ApiResponse where T: Serialize, { pub success: bool, pub data: Option, pub error: Option, } impl ApiResponse where T: Serialize, { pub fn ok(data: T) -> Self { Self { success: true, data: Some(data), error: None, } } } impl ApiResponse<()> { pub fn empty() -> Self { Self { success: true, data: Some(()), error: None, } } pub fn err(message: impl Into) -> Self { Self { success: false, data: None, error: Some(message.into()), } } } #[derive(Debug, Deserialize)] pub struct PageQuery { pub limit: Option, pub offset: Option, }