oxyde_cloud_common/
net.rs1use headers_core::{Header, HeaderName, HeaderValue};
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct LoginResponse {
6 pub username: String,
7}
8
9#[derive(Serialize, Deserialize, Debug, Clone)]
10pub struct Team {
11 pub slug: String,
12 pub name: String,
13}
14
15#[derive(Serialize, Deserialize, Debug, Clone)]
16pub struct NewAppRequest {
17 pub team_slug: String,
18 pub app_slug: String,
19}
20
21#[derive(Serialize, Deserialize, Debug, Clone)]
22pub struct NewTeamRequest {
23 pub team_slug: String,
24}
25
26#[derive(Serialize, Deserialize, Debug, Clone)]
27pub struct CheckAvailabilityResponse {
28 pub available: bool,
29}
30
31#[derive(Serialize, Deserialize, Debug, Clone)]
32pub struct SetTeamNameRequest {
33 pub team_slug: String,
34 pub team_name: String,
35}
36
37#[derive(Serialize, Deserialize, Debug, Clone)]
38pub struct LogRequest {
39 pub name: String,
40}
41
42#[derive(Serialize, Deserialize, Debug, Clone)]
43pub struct LogResponse {
44 pub log: String,
45}
46
47#[derive(Serialize, Deserialize, Debug, Clone)]
48pub struct AppMeta {
49 pub app_slug: String,
50}
51
52static NAME: HeaderName = HeaderName::from_static("app-meta");
53
54impl AppMeta {
55 pub fn to_string_value(&self) -> String {
56 self.app_slug.clone()
57 }
58}
59
60impl Header for AppMeta {
61 fn name() -> &'static HeaderName {
62 &NAME
63 }
64
65 fn decode<'i, I>(values: &mut I) -> Result<Self, headers_core::Error>
66 where
67 Self: Sized,
68 I: Iterator<Item = &'i HeaderValue>,
69 {
70 values
71 .next()
72 .and_then(|v| v.to_str().ok())
73 .map(|v| Self {
74 app_slug: v.to_string(),
75 })
76 .ok_or_else(headers_core::Error::invalid)
77 }
78
79 fn encode<E: Extend<HeaderValue>>(&self, values: &mut E) {
80 values.extend([
81 HeaderValue::from_str(&self.to_string_value()).expect("invalid header value")
82 ]);
83 }
84}
85
86#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq)]
87#[serde(rename_all = "lowercase")]
88pub enum DeploymentStatus {
89 Pending = 0,
90 Success = 1,
91 Failure = 2,
92}
93
94impl From<i16> for DeploymentStatus {
95 fn from(value: i16) -> Self {
96 match value {
97 0 => DeploymentStatus::Pending,
98 1 => DeploymentStatus::Success,
99 _ => DeploymentStatus::Failure,
100 }
101 }
102}
103
104#[derive(Serialize, Deserialize, Debug, Clone)]
105pub struct SuccessResponse {
106 pub success: bool,
107}
108
109impl Default for SuccessResponse {
110 fn default() -> Self {
111 Self { success: true }
112 }
113}