Refactor write_frame

This commit is contained in:
Bastian Gruber 2023-04-24 23:46:41 +02:00
parent ebf41ecb05
commit f4eb7213ab
No known key found for this signature in database
GPG key ID: BE9F8C772B188CBF

View file

@ -61,13 +61,12 @@ impl Connection {
} }
} }
pub async fn write_frame(&mut self, frame: &Frame) -> crate::Result<()> { pub async fn write_frame(&mut self, frame: &Frame) -> tokio::io::Result<()> {
debug!(?frame); debug!(?frame);
if let Frame::Response(mean) = frame { if let Frame::Response(mean) = frame {
let _ = self.stream.write(&[mean.to_ne_bytes()[0]]).await?; let res = self.stream.write(&mean.to_ne_bytes()).await?;
let _ = self.stream.flush().await?; info!("Write frame Response to stream");
info!("Wrote frame to stream"); return self.stream.flush().await;
return Ok(());
} }
Err("Wrong frame".into()) Err("Wrong frame".into())