use tokio::io::{AsyncWrite, AsyncWriteExt};
pub struct ProxyWriter {
write_stream: Box<dyn AsyncWrite + Unpin + Send>,
}
impl ProxyWriter {
pub fn new<W>(write_stream: W) -> Self
where
W: AsyncWrite + Unpin + Send + 'static,
{
Self {
write_stream: Box::new(write_stream),
}
}
pub async fn shutdown(&mut self) -> std::io::Result<()> {
self.write_stream.shutdown().await
}
pub async fn write(&mut self, buffer: &[u8]) -> std::io::Result<()> {
self.write_stream.write_all(buffer).await
}
}