use crate::Schema;
#[derive(Debug, Clone)]
pub(crate) struct MessageSchema {
pub encoding: String,
pub schema: Schema,
}
#[derive(Debug, Clone)]
pub struct ServiceSchema {
name: String,
request: Option<MessageSchema>,
response: Option<MessageSchema>,
}
impl ServiceSchema {
#[must_use]
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
request: None,
response: None,
}
}
#[must_use]
pub fn with_request(mut self, encoding: impl Into<String>, schema: Schema) -> Self {
self.request = Some(MessageSchema {
encoding: encoding.into(),
schema,
});
self
}
#[must_use]
pub fn with_response(mut self, encoding: impl Into<String>, schema: Schema) -> Self {
self.response = Some(MessageSchema {
encoding: encoding.into(),
schema,
});
self
}
pub fn name(&self) -> &str {
&self.name
}
pub(crate) fn request(&self) -> Option<&MessageSchema> {
self.request.as_ref()
}
pub(crate) fn response(&self) -> Option<&MessageSchema> {
self.response.as_ref()
}
}