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