You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

22 lines
539 B

use serde::{Deserialize, Serialize};
#[derive(PartialEq, Debug, Clone, Serialize, Deserialize, new)]
pub struct ApiResponse<T> {
success: bool,
response: T,
}
impl<T: Serialize> ApiResponse<T> {
pub fn is_success(&self) -> bool {
self.success
}
pub fn response(&self) -> &T {
&self.response
}
pub fn successful(response: T) -> ApiResponse<T> {
ApiResponse::new(true, response)
}
pub fn failure(response: T) -> ApiResponse<T> {
ApiResponse::new(false, response)
}
}