this repo has no description
1use crate::types::Did;
2use axum::{Json, response::IntoResponse};
3use serde::Serialize;
4
5#[derive(Debug, Serialize)]
6pub struct EmptyResponse {}
7
8impl EmptyResponse {
9 pub fn ok() -> impl IntoResponse {
10 Json(Self {})
11 }
12}
13
14#[derive(Debug, Serialize)]
15pub struct SuccessResponse {
16 pub success: bool,
17}
18
19impl SuccessResponse {
20 pub fn ok() -> impl IntoResponse {
21 Json(Self { success: true })
22 }
23}
24
25#[derive(Debug, Serialize)]
26pub struct DidResponse {
27 pub did: Did,
28}
29
30impl DidResponse {
31 pub fn response(did: impl Into<Did>) -> impl IntoResponse {
32 Json(Self { did: did.into() })
33 }
34}
35
36#[derive(Debug, Serialize)]
37#[serde(rename_all = "camelCase")]
38pub struct TokenRequiredResponse {
39 pub token_required: bool,
40}
41
42impl TokenRequiredResponse {
43 pub fn response(required: bool) -> impl IntoResponse {
44 Json(Self {
45 token_required: required,
46 })
47 }
48}
49
50#[derive(Debug, Serialize)]
51#[serde(rename_all = "camelCase")]
52pub struct HasPasswordResponse {
53 pub has_password: bool,
54}
55
56impl HasPasswordResponse {
57 pub fn response(has_password: bool) -> impl IntoResponse {
58 Json(Self { has_password })
59 }
60}
61
62#[derive(Debug, Serialize)]
63pub struct VerifiedResponse {
64 pub verified: bool,
65}
66
67impl VerifiedResponse {
68 pub fn response(verified: bool) -> impl IntoResponse {
69 Json(Self { verified })
70 }
71}
72
73#[derive(Debug, Serialize)]
74pub struct EnabledResponse {
75 pub enabled: bool,
76}
77
78impl EnabledResponse {
79 pub fn response(enabled: bool) -> impl IntoResponse {
80 Json(Self { enabled })
81 }
82}
83
84#[derive(Debug, Serialize)]
85pub struct StatusResponse {
86 pub status: String,
87}
88
89impl StatusResponse {
90 pub fn response(status: impl Into<String>) -> impl IntoResponse {
91 Json(Self {
92 status: status.into(),
93 })
94 }
95}
96
97#[derive(Debug, Serialize)]
98#[serde(rename_all = "camelCase")]
99pub struct DidDocumentResponse {
100 pub did_document: serde_json::Value,
101}
102
103impl DidDocumentResponse {
104 pub fn response(did_document: serde_json::Value) -> impl IntoResponse {
105 Json(Self { did_document })
106 }
107}
108
109#[derive(Debug, Serialize)]
110pub struct OptionsResponse<T: Serialize> {
111 pub options: T,
112}
113
114impl<T: Serialize> OptionsResponse<T> {
115 pub fn new(options: T) -> Json<Self> {
116 Json(Self { options })
117 }
118}