1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use errors::Result;
use {Flavor, Loc, RpReg, Translate, Translator};
#[derive(Debug, Clone, Serialize, Default)]
pub struct RpServiceBodyHttp {
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<Loc<String>>,
}
decl_body!(pub struct RpServiceBody<F> {
pub http: RpServiceBodyHttp,
pub endpoints: Vec<Loc<F::Endpoint>>,
});
impl<F: 'static, T> Translate<T> for RpServiceBody<F>
where
F: Flavor,
T: Translator<Source = F>,
{
type Source = F;
type Out = RpServiceBody<T::Target>;
fn translate(self, translator: &T) -> Result<RpServiceBody<T::Target>> {
translator.visit(&self.name)?;
let name = translator.translate_local_name(RpReg::Service, self.name)?;
let endpoints = self.endpoints
.into_iter()
.map(|e| Loc::and_then(e, |e| translator.translate_endpoint(e)))
.collect::<Result<Vec<_>>>()?;
Ok(RpServiceBody {
name: name,
ident: self.ident,
comment: self.comment,
decls: self.decls.translate(translator)?,
http: self.http,
endpoints: endpoints,
})
}
}