From 325c834e2d157d22b06e673d014352f34af3410b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E9=80=B8?= Date: Wed, 25 Dec 2024 01:09:22 +0900 Subject: [PATCH] feat(io): use IoBuf instead of Deref --- compio-io/src/read/managed.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/compio-io/src/read/managed.rs b/compio-io/src/read/managed.rs index 7ff35219..5c75b191 100644 --- a/compio-io/src/read/managed.rs +++ b/compio-io/src/read/managed.rs @@ -1,4 +1,6 @@ -use std::{io::Cursor, ops::Deref}; +use std::io::Cursor; + +use compio_buf::IoBuf; use crate::IoResult; @@ -9,7 +11,7 @@ pub trait AsyncReadManaged { /// Buffer pool type type BufferPool; /// Filled buffer type - type Buffer: Deref; + type Buffer: IoBuf; /// Read some bytes from this source with [`BufferPool`] and return /// a [`Buffer`]. @@ -30,7 +32,7 @@ pub trait AsyncReadManagedAt { /// Buffer pool type type BufferPool; /// Filled buffer type - type Buffer: Deref; + type Buffer: IoBuf; /// Read some bytes from this source at position with [`BufferPool`] and /// return a [`Buffer`]. @@ -59,7 +61,7 @@ impl AsyncReadManaged for Cursor { .get_ref() .read_managed_at(pos, buffer_pool, len) .await?; - self.set_position(pos + buf.len() as u64); + self.set_position(pos + buf.buf_len() as u64); Ok(buf) } }