Skip to main content

PDUWithData

Struct PDUWithData 

Source
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: bool

Implementations§

Source§

impl<T> PDUWithData<T, Bytes>

Source

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>

Source

pub fn new_request(header_buf: [u8; 48], cfg: &Config) -> Self

Creates a new PDUWithData request instance with a mutable body.

Source

pub fn parse_with_buff_mut(&mut self, buf: BytesMut) -> Result<()>

Parses the PDU payload from a mutable buffer, verifying digests.

Source

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>
where T: BasicHeaderSegment, B: Deref<Target = [u8]>,

Source

pub fn header_view(&self) -> Result<&T>

Returns an immutable view of the PDU’s header.

Source

pub fn header_view_mut(&mut self) -> Result<&mut T>

Returns a mutable view of the PDU’s header.

Source

pub fn additional_header(&self) -> Result<&[u8]>

Returns a slice of the Additional Header Segment (AHS).

Source

pub fn data(&self) -> Result<&[u8]>

Returns a slice of the PDU’s data segment.

Source

pub fn rebind_pdu<U>(self) -> Result<PDUWithData<U, B>>

Rebinds the PDU to a different header type.

Source§

impl<T> PDUWithData<T, Bytes>

Source

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>

Source§

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)>

Finalize and return the already-laid-out body as Bytes. Ensures HeaderDigest slot exists (even for zero DATA), appends pad(DATA) and DataDigest.

Source§

type Body = Bytes

Source§

type Header = [u8; 48]

The concrete buffer type used to return the encoded header.
Source§

impl<T, Body: Clone> Clone for PDUWithData<T, Body>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T, B> Debug for PDUWithData<T, B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: PartialEq, Body: PartialEq> PartialEq for PDUWithData<T, Body>

Source§

fn eq(&self, other: &PDUWithData<T, Body>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'ctx> StateMachineCtx<LoginCtx<'ctx>, PDUWithData<LoginResponse>> for LoginCtx<'ctx>

Source§

async fn execute( &mut self, _cancel: &CancellationToken, ) -> Result<PduResponse<LoginResponse>>

Executes the state machine to completion.
Source§

impl<'ctx> StateMachineCtx<LogoutCtx<'ctx>, PDUWithData<LogoutResponse>> for LogoutCtx<'ctx>

Source§

async fn execute( &mut self, _cancel: &CancellationToken, ) -> Result<PduResponse<LogoutResponse>>

Executes the state machine to completion.
Source§

impl<'s> StateMachineCtx<NopCtx<'s>, PDUWithData<NopInResponse>> for NopCtx<'s>

Source§

async fn execute( &mut self, _cancel: &CancellationToken, ) -> Result<PduResponse<NopInResponse>>

Executes the state machine to completion.
Source§

impl<'ctx> StateMachineCtx<TurCtx<'ctx>, PDUWithData<ScsiCommandResponse>> for TurCtx<'ctx>

Source§

async fn execute( &mut self, _cancel: &CancellationToken, ) -> Result<PduResponse<ScsiCommandResponse>>

Executes the state machine to completion.
Source§

impl<T: PartialEq, Body: PartialEq> StructuralPartialEq for PDUWithData<T, Body>

Auto Trait Implementations§

§

impl<T, Body> Freeze for PDUWithData<T, Body>
where Body: Freeze,

§

impl<T, Body> RefUnwindSafe for PDUWithData<T, Body>
where Body: RefUnwindSafe, T: RefUnwindSafe,

§

impl<T, Body> Send for PDUWithData<T, Body>
where Body: Send, T: Send,

§

impl<T, Body> Sync for PDUWithData<T, Body>
where Body: Sync, T: Sync,

§

impl<T, Body> Unpin for PDUWithData<T, Body>
where Body: Unpin, T: Unpin,

§

impl<T, Body> UnsafeUnpin for PDUWithData<T, Body>
where Body: UnsafeUnpin,

§

impl<T, Body> UnwindSafe for PDUWithData<T, Body>
where Body: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<B> ToBytes for B
where B: Builder,

Source§

type Body = <B as Builder>::Body

Source§

type Header = <B as Builder>::Header

Source§

fn to_bytes( &mut self, max_recv_data_segment_length: usize, ) -> Result<(<B as ToBytes>::Header, <B as ToBytes>::Body), Error>

Consume the PDU builder or object and produce: Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more