1use crate::*;
2
3pub trait ProtoService {
7 fn proto_schema() -> Service;
8}
9
10#[derive(Debug, PartialEq, Builder)]
12#[cfg_attr(feature = "std", derive(Template))]
13#[cfg_attr(feature = "std", template(path = "service.proto.j2"))]
14#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
15#[non_exhaustive]
16pub struct Service {
17 pub name: FixedStr,
18 pub file: FixedStr,
19 pub options: Vec<ProtoOption>,
20 pub handlers: Vec<ServiceHandler>,
21 pub package: FixedStr,
22}
23
24impl Service {
25 #[cfg(feature = "std")]
27 pub fn render_schema(&self) -> Result<String, askama::Error> {
28 self.render()
29 }
30}
31
32#[derive(Debug, PartialEq, Builder)]
34#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
35#[non_exhaustive]
36pub struct ServiceHandler {
37 pub name: FixedStr,
38 pub options: Vec<ProtoOption>,
39 pub request: ProtoPath,
40 pub response: ProtoPath,
41}