diff --git a/src/mpvctl/mpv_framed.rs b/src/mpvctl/mpv_framed.rs index 757009a..9cb5de7 100644 --- a/src/mpvctl/mpv_framed.rs +++ b/src/mpvctl/mpv_framed.rs @@ -18,8 +18,19 @@ impl MpvFramed { pub async fn read_frame( &mut self, ) -> Result, Box> { - // - todo!() + loop { + if let Some(frame) = self.parse_frame()? { + return Ok(Some(frame)); + } + + if 0 == self.socket_read.read_buf(&mut self.buffer).await? { + if self.buffer.is_empty() { + return Ok(None); + } else { + return Err("connection reset by peer".into()); + } + } + } } fn parse_frame(&mut self) -> Result, Box> {