|
From: | Paolo Bonzini |
Subject: | Re: [PATCH 08/11] rust/block: Add driver module |
Date: | Wed, 12 Feb 2025 17:43:57 +0100 |
User-agent: | Mozilla Thunderbird |
On 2/11/25 22:43, Kevin Wolf wrote:
+ /// Reads data from the child node into a linear typed buffer. + pub async fn read<T: IoBuffer + ?Sized>(&self, offset: u64, buf: &mut T) -> io::Result<()> { + unsafe { + self.read_raw(offset, buf.buffer_len(), buf.buffer_mut_ptr()) + .await + } + } + + /// Reads data from the child node into a linear, potentially uninitialised typed buffer. + pub async fn read_uninit<T: SizedIoBuffer>( + &self, + offset: u64, + mut buf: MaybeUninit<T>,
I think Rust doesn't guarantee no copies here, so maybe this could be pub async fn read_uninit<T: SizedIoBuffer>( &self, offset: u64, buf: &mut MaybeUninit<T>, ) -> io::Result<&mut T> using assume_init_mut(). Paolo
[Prev in Thread] | Current Thread | [Next in Thread] |