Skip to content

Commit

Permalink
feat(io): use IoBuf instead of Deref
Browse files Browse the repository at this point in the history
  • Loading branch information
Berrysoft committed Dec 24, 2024
1 parent ec3dd36 commit 325c834
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions compio-io/src/read/managed.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use std::{io::Cursor, ops::Deref};
use std::io::Cursor;

use compio_buf::IoBuf;

use crate::IoResult;

Expand All @@ -9,7 +11,7 @@ pub trait AsyncReadManaged {
/// Buffer pool type
type BufferPool;
/// Filled buffer type
type Buffer: Deref<Target = [u8]>;
type Buffer: IoBuf;

/// Read some bytes from this source with [`BufferPool`] and return
/// a [`Buffer`].
Expand All @@ -30,7 +32,7 @@ pub trait AsyncReadManagedAt {
/// Buffer pool type
type BufferPool;
/// Filled buffer type
type Buffer: Deref<Target = [u8]>;
type Buffer: IoBuf;

/// Read some bytes from this source at position with [`BufferPool`] and
/// return a [`Buffer`].
Expand Down Expand Up @@ -59,7 +61,7 @@ impl<A: AsyncReadManagedAt> AsyncReadManaged for Cursor<A> {
.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)
}
}

0 comments on commit 325c834

Please sign in to comment.