use std::sync::Arc;
use crate::format::ErasedFormat;
#[derive(Debug, Clone)]
pub struct NegotiatedFormat {
response_format: Arc<dyn ErasedFormat>,
request_format: Option<Arc<dyn ErasedFormat>>,
}
impl NegotiatedFormat {
pub fn response_only(response_format: Arc<dyn ErasedFormat>) -> Self {
Self {
response_format,
request_format: None,
}
}
pub fn with_request_format(
response_format: Arc<dyn ErasedFormat>,
request_format: Arc<dyn ErasedFormat>,
) -> Self {
Self {
response_format,
request_format: Some(request_format),
}
}
pub fn response_format(&self) -> &Arc<dyn ErasedFormat> {
&self.response_format
}
pub fn request_format(&self) -> Option<&Arc<dyn ErasedFormat>> {
self.request_format.as_ref()
}
}