pub struct PDUWithData<T, Body = Bytes> {
pub header_buf: [u8; 48],
pub header_digest: Option<U32<BigEndian>>,
pub data_digest: Option<U32<BigEndian>>,
pub is_x86: bool,
/* private fields */
}Expand description
A generic container for an iSCSI Protocol Data Unit (PDU).
This struct holds the PDU’s header, payload (data), and digest information. It is generic over the body type, allowing it to be used for both requests (with a mutable body) and responses (with an immutable body).
Fields§
§header_buf: [u8; 48]The raw buffer for the Basic Header Segment (BHS).
header_digest: Option<U32<BigEndian>>The optional header digest value.
data_digest: Option<U32<BigEndian>>The optional data digest value.
is_x86: boolImplementations§
Source§impl<T> PDUWithData<T, Bytes>
impl<T> PDUWithData<T, Bytes>
Sourcepub fn from_header_slice(header_buf: [u8; 48], cfg: &Config) -> Self
pub fn from_header_slice(header_buf: [u8; 48], cfg: &Config) -> Self
Creates a new PDUWithData instance from a header slice and
configuration.
Source§impl<T> PDUWithData<T, BytesMut>
impl<T> PDUWithData<T, BytesMut>
Sourcepub fn new_request(header_buf: [u8; 48], cfg: &Config) -> Self
pub fn new_request(header_buf: [u8; 48], cfg: &Config) -> Self
Creates a new PDUWithData request instance with a mutable body.
Sourcepub fn parse_with_buff_mut(&mut self, buf: BytesMut) -> Result<()>
pub fn parse_with_buff_mut(&mut self, buf: BytesMut) -> Result<()>
Parses the PDU payload from a mutable buffer, verifying digests.
Sourcepub fn parse_with_buff_ref(&mut self, buf: &BytesMut) -> Result<()>
pub fn parse_with_buff_ref(&mut self, buf: &BytesMut) -> Result<()>
Parses the PDU payload from a reference to a mutable buffer.
Source§impl<T, B> PDUWithData<T, B>
impl<T, B> PDUWithData<T, B>
Sourcepub fn header_view(&self) -> Result<&T>where
T: FromBytes + ZeroCopyType,
pub fn header_view(&self) -> Result<&T>where
T: FromBytes + ZeroCopyType,
Returns an immutable view of the PDU’s header.
Sourcepub fn header_view_mut(&mut self) -> Result<&mut T>where
T: FromBytes + ZeroCopyType,
pub fn header_view_mut(&mut self) -> Result<&mut T>where
T: FromBytes + ZeroCopyType,
Returns a mutable view of the PDU’s header.
Sourcepub fn additional_header(&self) -> Result<&[u8]>where
T: FromBytes + ZeroCopyType,
pub fn additional_header(&self) -> Result<&[u8]>where
T: FromBytes + ZeroCopyType,
Returns a slice of the Additional Header Segment (AHS).
Sourcepub fn data(&self) -> Result<&[u8]>where
T: FromBytes + ZeroCopyType,
pub fn data(&self) -> Result<&[u8]>where
T: FromBytes + ZeroCopyType,
Returns a slice of the PDU’s data segment.
Sourcepub fn rebind_pdu<U>(self) -> Result<PDUWithData<U, B>>where
U: BasicHeaderSegment,
pub fn rebind_pdu<U>(self) -> Result<PDUWithData<U, B>>where
U: BasicHeaderSegment,
Rebinds the PDU to a different header type.
Source§impl<T> PDUWithData<T, Bytes>
impl<T> PDUWithData<T, Bytes>
Sourcepub fn parse_with_buff(&mut self, buf: &Bytes) -> Result<()>
pub fn parse_with_buff(&mut self, buf: &Bytes) -> Result<()>
Parses the PDU payload from an immutable buffer, verifying digests.
Trait Implementations§
Source§impl<T> Builder for PDUWithData<T, BytesMut>
impl<T> Builder for PDUWithData<T, BytesMut>
Source§fn append_data(&mut self, more: &[u8])
fn append_data(&mut self, more: &[u8])
On the first call, if HeaderDigest is enabled, reserve exactly one 4-byte slot for it right before DATA; then append DATA and update DataSegmentLength.
Source§fn build(
&mut self,
max_recv_data_segment_length: usize,
) -> Result<(Self::Header, Self::Body)>
fn build( &mut self, max_recv_data_segment_length: usize, ) -> Result<(Self::Header, Self::Body)>
Finalize and return the already-laid-out body as Bytes. Ensures HeaderDigest slot exists (even for zero DATA), appends pad(DATA) and DataDigest.
type Body = Bytes
Source§impl<T, Body: Clone> Clone for PDUWithData<T, Body>
impl<T, Body: Clone> Clone for PDUWithData<T, Body>
Source§impl<T, B> Debug for PDUWithData<T, B>where
T: BasicHeaderSegment + SendingData + FromBytes + Debug + ZeroCopyType,
B: Deref<Target = [u8]>,
impl<T, B> Debug for PDUWithData<T, B>where
T: BasicHeaderSegment + SendingData + FromBytes + Debug + ZeroCopyType,
B: Deref<Target = [u8]>,
Source§impl<T: PartialEq, Body: PartialEq> PartialEq for PDUWithData<T, Body>
impl<T: PartialEq, Body: PartialEq> PartialEq for PDUWithData<T, Body>
Source§fn eq(&self, other: &PDUWithData<T, Body>) -> bool
fn eq(&self, other: &PDUWithData<T, Body>) -> bool
self and other values to be equal, and is used by ==.