1
1
use crate :: { guid, Char16 , Char8 , Event , Guid , Ipv4Address , Ipv6Address , Status } ;
2
2
use core:: ffi:: c_void;
3
3
use core:: fmt:: { self , Debug , Formatter } ;
4
+ use core:: ptr;
4
5
5
- #[ derive( Debug ) ]
6
+ #[ derive( Debug , Default ) ]
6
7
#[ repr( C ) ]
7
8
pub struct HttpConfigData {
8
9
pub http_version : HttpVersion ,
@@ -12,14 +13,15 @@ pub struct HttpConfigData {
12
13
}
13
14
14
15
newtype_enum ! {
16
+ #[ derive( Default ) ]
15
17
pub enum HttpVersion : i32 => {
16
18
HTTP_VERSION_10 = 0 ,
17
19
HTTP_VERSION_11 = 1 ,
18
20
HTTP_VERSION_UNSUPPORTED = 2 ,
19
21
}
20
22
}
21
23
22
- #[ derive( Debug ) ]
24
+ #[ derive( Clone , Copy , Debug , Default , Eq , PartialEq , Ord , PartialOrd , Hash ) ]
23
25
#[ repr( C ) ]
24
26
pub struct HttpV4AccessPoint {
25
27
pub use_default_addr : bool ,
@@ -28,7 +30,7 @@ pub struct HttpV4AccessPoint {
28
30
pub local_port : u16 ,
29
31
}
30
32
31
- #[ derive( Debug ) ]
33
+ #[ derive( Clone , Copy , Debug , Default , Eq , PartialEq , Ord , PartialOrd , Hash ) ]
32
34
#[ repr( C ) ]
33
35
pub struct HttpV6AccessPoint {
34
36
pub local_address : Ipv6Address ,
@@ -48,6 +50,14 @@ impl Debug for HttpAccessPoint {
48
50
}
49
51
}
50
52
53
+ impl Default for HttpAccessPoint {
54
+ fn default ( ) -> Self {
55
+ Self {
56
+ ipv4_node : ptr:: null ( ) ,
57
+ }
58
+ }
59
+ }
60
+
51
61
#[ derive( Debug ) ]
52
62
#[ repr( C ) ]
53
63
pub struct HttpToken {
@@ -56,6 +66,16 @@ pub struct HttpToken {
56
66
pub message : * mut HttpMessage ,
57
67
}
58
68
69
+ impl Default for HttpToken {
70
+ fn default ( ) -> Self {
71
+ Self {
72
+ event : ptr:: null_mut ( ) ,
73
+ status : Status :: SUCCESS ,
74
+ message : ptr:: null_mut ( ) ,
75
+ }
76
+ }
77
+ }
78
+
59
79
#[ derive( Debug ) ]
60
80
#[ repr( C ) ]
61
81
pub struct HttpMessage {
@@ -66,14 +86,36 @@ pub struct HttpMessage {
66
86
pub body : * mut c_void ,
67
87
}
68
88
89
+ impl Default for HttpMessage {
90
+ fn default ( ) -> Self {
91
+ Self {
92
+ data : HttpRequestOrResponse :: default ( ) ,
93
+ header_count : 0 ,
94
+ header : ptr:: null_mut ( ) ,
95
+ body_length : 0 ,
96
+ body : ptr:: null_mut ( ) ,
97
+ }
98
+ }
99
+ }
100
+
69
101
#[ derive( Debug ) ]
70
102
#[ repr( C ) ]
71
103
pub struct HttpRequestData {
72
104
pub method : HttpMethod ,
73
105
pub url : * const Char16 ,
74
106
}
75
107
108
+ impl Default for HttpRequestData {
109
+ fn default ( ) -> Self {
110
+ Self {
111
+ method : HttpMethod :: default ( ) ,
112
+ url : ptr:: null ( ) ,
113
+ }
114
+ }
115
+ }
116
+
76
117
newtype_enum ! {
118
+ #[ derive( Default ) ]
77
119
pub enum HttpMethod : i32 => {
78
120
GET = 0 ,
79
121
POST = 1 ,
@@ -88,7 +130,7 @@ newtype_enum! {
88
130
}
89
131
}
90
132
91
- #[ derive( Debug ) ]
133
+ #[ derive( Debug , Default ) ]
92
134
#[ repr( C ) ]
93
135
pub struct HttpResponseData {
94
136
pub status_code : HttpStatusCode ,
@@ -107,14 +149,32 @@ impl Debug for HttpRequestOrResponse {
107
149
}
108
150
}
109
151
152
+ impl Default for HttpRequestOrResponse {
153
+ fn default ( ) -> Self {
154
+ Self {
155
+ request : ptr:: null ( ) ,
156
+ }
157
+ }
158
+ }
159
+
110
160
#[ derive( Clone , Debug ) ]
111
161
#[ repr( C ) ]
112
162
pub struct HttpHeader {
113
163
pub field_name : * const Char8 ,
114
164
pub field_value : * const Char8 ,
115
165
}
116
166
167
+ impl Default for HttpHeader {
168
+ fn default ( ) -> Self {
169
+ Self {
170
+ field_name : ptr:: null ( ) ,
171
+ field_value : ptr:: null ( ) ,
172
+ }
173
+ }
174
+ }
175
+
117
176
newtype_enum ! {
177
+ #[ derive( Default ) ]
118
178
pub enum HttpStatusCode : i32 => {
119
179
STATUS_UNSUPPORTED = 0 ,
120
180
STATUS_100_CONTINUE = 1 ,
0 commit comments