apikit/
payload.rs

1//! Useful prefabricated payloads.
2
3use serde::{Deserialize, Serialize};
4
5/// Standard message response.
6///
7/// Use when returning a single piece of unstructured information from your axum route. (e.g. "Upload Complete")
8#[derive(Clone, Debug, Deserialize, Serialize)]
9#[serde(deny_unknown_fields)]
10pub struct MessageResponse {
11    pub message: String,
12}
13
14impl MessageResponse {
15    pub fn new<S: Into<String>>(message: S) -> Self {
16        Self {
17            message: message.into(),
18        }
19    }
20}
21
22/// Standard error response.
23///
24/// Contains the error body serialized as a string.
25#[derive(Clone, Debug, Deserialize, Serialize)]
26#[serde(deny_unknown_fields)]
27pub struct ErrorResponse {
28    pub error: String,
29}