Skip to main content

BasicHeaderSegment

Trait BasicHeaderSegment 

Source
pub trait BasicHeaderSegment: Sized + SendingData {
    // Required methods
    fn to_bhs_bytes(&self, buf: &mut [u8]) -> Result<()>;
    fn get_opcode(&self) -> Result<BhsOpcode>;
    fn get_initiator_task_tag(&self) -> u32;
    fn get_ahs_length_bytes(&self) -> usize;
    fn set_ahs_length_bytes(&mut self, len: u8);
    fn get_data_length_bytes(&self) -> usize;
    fn set_data_length_bytes(&mut self, len: u32);

    // Provided methods
    fn total_length_bytes(&self) -> usize { ... }
    fn get_header_diggest(&self, enable_header_digest: bool) -> usize { ... }
    fn get_data_diggest(&self, enable_data_digest: bool) -> usize { ... }
}
Expand description

Common functionality for any iSCSI PDU Basic Header Segment (BHS)

A BHS is always 48 bytes long according to RFC 7143; higher‐level PDUs then may carry additional AHS sections, a variable-length DataSegment, and optional digests. This trait encapsulates:

  1. extracting lengths out of the BHS,
  2. appending to the DataSegment,
  3. and finally building the full wire format.

All iSCSI PDU types must implement this trait to provide basic header operations.

Required Methods§

Source

fn to_bhs_bytes(&self, buf: &mut [u8]) -> Result<()>

Source

fn get_opcode(&self) -> Result<BhsOpcode>

first u8 of BHS

Source

fn get_initiator_task_tag(&self) -> u32

Expose Initiator Task Tag of this PDU

Source

fn get_ahs_length_bytes(&self) -> usize

Number of extra AHS bytes (always a multiple of 4).

Source

fn set_ahs_length_bytes(&mut self, len: u8)

Number of extra AHS bytes (always a multiple of 4).

Source

fn get_data_length_bytes(&self) -> usize

Get number of actual payload bytes in the DataSegment.

Source

fn set_data_length_bytes(&mut self, len: u32)

Set number of actual payload bytes in the DataSegment.

Provided Methods§

Source

fn total_length_bytes(&self) -> usize

Number of actual payload bytes in the DataSegment.

Source

fn get_header_diggest(&self, enable_header_digest: bool) -> usize

Source

fn get_data_diggest(&self, enable_data_digest: bool) -> usize

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: BasicHeaderSegment> BasicHeaderSegment for &mut T

Implementors§