use crate::{
FoxgloveError,
websocket::streams::{Acceptor, ServerStream, TlsIdentity},
};
use tokio_util::either::Either;
pub(crate) type TlsStream<S> = S;
pub struct StreamConfiguration {}
impl StreamConfiguration {
pub fn new(identity: Option<&TlsIdentity>) -> Result<Self, FoxgloveError> {
if identity.is_some() {
return Err(FoxgloveError::ConfigurationError(
"TLS is not enabled".to_string(),
));
}
Ok(Self {})
}
}
impl Acceptor for StreamConfiguration {
async fn accept(
&self,
stream: tokio::net::TcpStream,
) -> Result<ServerStream<tokio::net::TcpStream>, crate::FoxgloveError> {
Ok(Either::Left(stream))
}
fn accepts_tls(&self) -> bool {
false
}
}