From ec3dd3699d40695da6138c1918164faab5ce0277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E9=80=B8?= Date: Mon, 9 Dec 2024 23:52:17 +0900 Subject: [PATCH] feat(io): owned managed buffer --- compio-io/src/read/managed.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/compio-io/src/read/managed.rs b/compio-io/src/read/managed.rs index 8a8d7040..7ff35219 100644 --- a/compio-io/src/read/managed.rs +++ b/compio-io/src/read/managed.rs @@ -1,4 +1,4 @@ -use std::{io::Cursor, ops::DerefMut}; +use std::{io::Cursor, ops::Deref}; use crate::IoResult; @@ -9,18 +9,18 @@ pub trait AsyncReadManaged { /// Buffer pool type type BufferPool; /// Filled buffer type - type Buffer<'a>: DerefMut; + type Buffer: Deref; /// Read some bytes from this source with [`BufferPool`] and return /// a [`Buffer`]. /// /// If `len` == 0, will use [`BufferPool`] inner buffer size as the max len, /// if `len` > 0, `min(len, inner buffer size)` will be the read max len - async fn read_managed<'a>( + async fn read_managed( &mut self, - buffer_pool: &'a Self::BufferPool, + buffer_pool: &Self::BufferPool, len: usize, - ) -> IoResult>; + ) -> IoResult; } /// # AsyncReadAtManaged @@ -30,30 +30,30 @@ pub trait AsyncReadManagedAt { /// Buffer pool type type BufferPool; /// Filled buffer type - type Buffer<'a>: DerefMut; + type Buffer: Deref; /// Read some bytes from this source at position with [`BufferPool`] and /// return a [`Buffer`]. /// /// If `len` == 0, will use [`BufferPool`] inner buffer size as the max len, /// if `len` > 0, `min(len, inner buffer size)` will be the read max len - async fn read_managed_at<'a>( + async fn read_managed_at( &self, pos: u64, - buffer_pool: &'a Self::BufferPool, + buffer_pool: &Self::BufferPool, len: usize, - ) -> IoResult>; + ) -> IoResult; } impl AsyncReadManaged for Cursor { - type Buffer<'a> = A::Buffer<'a>; + type Buffer = A::Buffer; type BufferPool = A::BufferPool; - async fn read_managed<'a>( + async fn read_managed( &mut self, - buffer_pool: &'a Self::BufferPool, + buffer_pool: &Self::BufferPool, len: usize, - ) -> IoResult> { + ) -> IoResult { let pos = self.position(); let buf = self .get_ref()