@@ -20,7 +20,8 @@ pub(crate) mod ser {
2020 use crate :: activity_flyio:: fly_http:: regions:: Region ;
2121 use crate :: exports:: activity_flyio:: fly_http:: machines:: {
2222 CpuKind , ExecResponse , GuestConfig , HostStatus , InitConfig , Machine , MachineConfig ,
23- MachineRestart , Mount , RestartPolicy , StopConfig ,
23+ MachineRestart , Mount , PortConfig , PortHandler , RestartPolicy , ServiceConfig ,
24+ ServiceProtocol , StopConfig ,
2425 } ;
2526 use serde:: de:: DeserializeOwned ;
2627 use serde:: { Deserialize , Serialize } ;
@@ -78,6 +79,7 @@ pub(crate) mod ser {
7879 restart : Option < MachineRestartSer > ,
7980 stop_config : Option < StopConfig > ,
8081 mounts : Option < Vec < Mount > > ,
82+ services : Option < Vec < ServiceConfigSer > > ,
8183 }
8284
8385 #[ derive( Serialize , Deserialize , Debug ) ]
@@ -161,6 +163,53 @@ pub(crate) mod ser {
161163 path : String ,
162164 }
163165
166+ #[ derive( Debug , Serialize , Deserialize ) ]
167+ pub ( crate ) struct PortConfigSer {
168+ port : u16 ,
169+ handlers : Vec < ToLowerWrapper < PortHandler > > ,
170+ }
171+ impl From < PortConfig > for PortConfigSer {
172+ fn from ( wit : PortConfig ) -> Self {
173+ PortConfigSer {
174+ port : wit. port ,
175+ handlers : wit. handlers . into_iter ( ) . map ( ToLowerWrapper ) . collect ( ) ,
176+ }
177+ }
178+ }
179+ impl From < PortConfigSer > for PortConfig {
180+ fn from ( ser : PortConfigSer ) -> PortConfig {
181+ PortConfig {
182+ port : ser. port ,
183+ handlers : ser. handlers . into_iter ( ) . map ( |wrapper| wrapper. 0 ) . collect ( ) ,
184+ }
185+ }
186+ }
187+
188+ #[ derive( Debug , Serialize , Deserialize ) ]
189+ pub ( crate ) struct ServiceConfigSer {
190+ internal_port : u16 ,
191+ protocol : ToLowerWrapper < ServiceProtocol > ,
192+ ports : Vec < PortConfigSer > ,
193+ }
194+ impl From < ServiceConfig > for ServiceConfigSer {
195+ fn from ( wit : ServiceConfig ) -> Self {
196+ ServiceConfigSer {
197+ internal_port : wit. internal_port ,
198+ protocol : ToLowerWrapper ( wit. protocol ) ,
199+ ports : wit. ports . into_iter ( ) . map ( PortConfigSer :: from) . collect ( ) ,
200+ }
201+ }
202+ }
203+ impl From < ServiceConfigSer > for ServiceConfig {
204+ fn from ( ser : ServiceConfigSer ) -> ServiceConfig {
205+ ServiceConfig {
206+ internal_port : ser. internal_port ,
207+ protocol : ser. protocol . 0 ,
208+ ports : ser. ports . into_iter ( ) . map ( PortConfig :: from) . collect ( ) ,
209+ }
210+ }
211+ }
212+
164213 #[ derive( Deserialize ) ]
165214 pub ( crate ) struct MachineCreateResponseSer {
166215 pub ( crate ) id : String ,
@@ -205,7 +254,8 @@ pub(crate) mod ser {
205254
206255 use std:: fmt:: Debug ;
207256 #[ derive( derive_more:: Debug ) ]
208- #[ debug( "{_0:?}" ) ]
257+ #[ debug( "{_0:?}" ) ] // Transparent debug
258+ // FIXME: Remove once wit-bindgen supports path-specific derives
209259 pub ( crate ) struct ToLowerWrapper < T : Debug + Serialize + DeserializeOwned > ( pub ( crate ) T ) ;
210260
211261 impl < T : Debug + Serialize + DeserializeOwned > Serialize for ToLowerWrapper < T > {
@@ -302,6 +352,9 @@ pub(crate) mod ser {
302352 init,
303353 stop_config : wit. stop_config ,
304354 mounts : wit. mounts ,
355+ services : wit
356+ . services
357+ . map ( |vec| vec. into_iter ( ) . map ( ServiceConfigSer :: from) . collect ( ) ) ,
305358 }
306359 }
307360 }
@@ -350,6 +403,9 @@ pub(crate) mod ser {
350403 init,
351404 stop_config,
352405 mounts : ser. mounts ,
406+ services : ser
407+ . services
408+ . map ( |vec| vec. into_iter ( ) . map ( ServiceConfig :: from) . collect ( ) ) ,
353409 }
354410 }
355411 }
0 commit comments