mirror of
https://github.com/rust-osdev/uefi-rs
synced 2026-08-26 18:26:05 -04:00
proto: bind SCSI/ATA/NVMe response accessors to &self
The response accessors returned `&'a` instead of borrowing from `self`. So any returned value was bound to the lifetime of the underlying buffer which is wrong semantics.
This commit is contained in:
parent
a09fabe0d7
commit
97a1dfcb65
3 changed files with 9 additions and 9 deletions
|
|
@ -333,13 +333,13 @@ pub struct AtaResponse<'a> {
|
|||
req: AtaRequest<'a>,
|
||||
}
|
||||
|
||||
impl<'a> AtaResponse<'a> {
|
||||
impl AtaResponse<'_> {
|
||||
/// Retrieves the status block from the response.
|
||||
///
|
||||
/// # Returns
|
||||
/// A reference to the [`AtaStatusBlock`] containing details about the status of the executed operation.
|
||||
#[must_use]
|
||||
pub const fn status(&self) -> &'a AtaStatusBlock {
|
||||
pub const fn status(&self) -> &AtaStatusBlock {
|
||||
// SAFETY: The memory is valid.
|
||||
unsafe {
|
||||
self.req
|
||||
|
|
@ -356,7 +356,7 @@ impl<'a> AtaResponse<'a> {
|
|||
/// # Returns
|
||||
/// `Option<&[u8]>`: A slice of the data read from the device, or `None` if no read buffer was used.
|
||||
#[must_use]
|
||||
pub const fn read_buffer(&self) -> Option<&'a [u8]> {
|
||||
pub const fn read_buffer(&self) -> Option<&[u8]> {
|
||||
if self.req.packet.in_data_buffer.is_null() {
|
||||
return None;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -241,13 +241,13 @@ pub struct NvmeResponse<'buffers> {
|
|||
req: NvmeRequest<'buffers>,
|
||||
completion: NvmeCompletion,
|
||||
}
|
||||
impl<'buffers> NvmeResponse<'buffers> {
|
||||
impl NvmeResponse<'_> {
|
||||
/// Returns the buffer containing transferred data from the device (if any).
|
||||
///
|
||||
/// # Returns
|
||||
/// `Option<&[u8]>`: A slice of the transfer buffer, or `None` if the request was started without.
|
||||
#[must_use]
|
||||
pub const fn transfer_buffer(&self) -> Option<&'buffers [u8]> {
|
||||
pub const fn transfer_buffer(&self) -> Option<&[u8]> {
|
||||
if self.req.packet.transfer_buffer.is_null() {
|
||||
return None;
|
||||
}
|
||||
|
|
@ -265,7 +265,7 @@ impl<'buffers> NvmeResponse<'buffers> {
|
|||
/// # Returns
|
||||
/// `Option<&[u8]>`: A slice of the metadata buffer, or `None` if the request was started without.
|
||||
#[must_use]
|
||||
pub const fn metadata_buffer(&self) -> Option<&'buffers [u8]> {
|
||||
pub const fn metadata_buffer(&self) -> Option<&[u8]> {
|
||||
if self.req.packet.meta_data_buffer.is_null() {
|
||||
return None;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ impl<'a> ScsiRequestBuilder<'a> {
|
|||
#[derive(Debug)]
|
||||
#[repr(transparent)]
|
||||
pub struct ScsiResponse<'a>(ScsiRequest<'a>);
|
||||
impl<'a> ScsiResponse<'a> {
|
||||
impl ScsiResponse<'_> {
|
||||
/// Retrieves the buffer containing data read from the device (if any).
|
||||
///
|
||||
/// # Returns
|
||||
|
|
@ -303,7 +303,7 @@ impl<'a> ScsiResponse<'a> {
|
|||
/// # Safety
|
||||
/// - If the buffer pointer is `NULL`, the method returns `None` and avoids dereferencing it.
|
||||
#[must_use]
|
||||
pub const fn read_buffer(&self) -> Option<&'a [u8]> {
|
||||
pub const fn read_buffer(&self) -> Option<&[u8]> {
|
||||
if self.0.packet.in_data_buffer.is_null() {
|
||||
return None;
|
||||
}
|
||||
|
|
@ -324,7 +324,7 @@ impl<'a> ScsiResponse<'a> {
|
|||
/// # Safety
|
||||
/// - If the buffer pointer is `NULL`, the method returns `None` and avoids dereferencing it.
|
||||
#[must_use]
|
||||
pub const fn sense_data(&self) -> Option<&'a [u8]> {
|
||||
pub const fn sense_data(&self) -> Option<&[u8]> {
|
||||
if self.0.packet.sense_data.is_null() {
|
||||
return None;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue