bee_api_types/
body.rs

1// Copyright 2020-2022 IOTA Stiftung
2// SPDX-License-Identifier: Apache-2.0
3
4use serde::Serialize;
5
6/// A marker trait to represent the data that can be included into `ErrorBody`.
7pub trait BodyInner {}
8
9/// Describes the response body of a unsuccessful HTTP request.
10#[derive(Clone, Debug, Serialize)]
11pub struct ErrorBody<T: BodyInner> {
12    pub error: T,
13}
14
15impl<T: BodyInner> ErrorBody<T> {
16    pub fn new(error: T) -> Self {
17        Self { error }
18    }
19}
20
21/// Describes the default error format.
22#[derive(Clone, Debug, Serialize)]
23pub struct DefaultErrorResponse {
24    pub code: String,
25    pub message: String,
26}
27
28impl BodyInner for DefaultErrorResponse {}