refactor(proto): replace anyhow with thiserror in readers

This commit is contained in:
Jindřich Moravec 2023-12-15 16:21:51 +01:00
parent 58c69928a1
commit da6410ce05
5 changed files with 80 additions and 23 deletions

View file

@ -3,7 +3,7 @@ use tokio::io::{AsyncBufRead, AsyncBufReadExt};
#[async_trait]
pub trait AsyncPeek {
async fn peek(&mut self, buf: &mut [u8]) -> std::io::Result<usize>;
async fn peek(&mut self, buf: &mut [u8]) -> tokio::io::Result<usize>;
}
#[async_trait]
@ -11,7 +11,7 @@ impl<T> AsyncPeek for T
where
T: AsyncBufRead + Unpin + Send,
{
async fn peek(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
async fn peek(&mut self, buf: &mut [u8]) -> tokio::io::Result<usize> {
let filled = self.fill_buf().await?;
if filled.len() >= buf.len() {
buf.copy_from_slice(&filled[..buf.len()]);