Skip to main content

WriteCtx

Struct WriteCtx 

Source
pub struct WriteCtx<'a> {
    pub conn: Arc<ClientConnection>,
    pub lun: u64,
    pub itt: u32,
    pub cmd_sn: Arc<AtomicU32>,
    pub exp_stat_sn: Arc<AtomicU32>,
    pub cdb: [u8; 16],
    pub payload: Vec<u8>,
    pub buf: [u8; 48],
    pub sent_bytes: usize,
    pub total_bytes: usize,
    pub last_response: Option<PduResponse<ScsiCommandResponse>>,
    /* private fields */
}
Expand description

This structure represents the context for a SCSI Write operation.

Fields§

§conn: Arc<ClientConnection>

The client connection.

§lun: u64

The Logical Unit Number.

§itt: u32

The Initiator Task Tag.

§cmd_sn: Arc<AtomicU32>

The Command Sequence Number.

§exp_stat_sn: Arc<AtomicU32>

The Expected Status Sequence Number.

§cdb: [u8; 16]

The SCSI Command Descriptor Block.

§payload: Vec<u8>

The data to be written.

§buf: [u8; 48]

A buffer for the BHS.

§sent_bytes: usize

The number of bytes that have been sent.

§total_bytes: usize

The total number of bytes to be sent.

§last_response: Option<PduResponse<ScsiCommandResponse>>

The last received command response.

Implementations§

Source§

impl<'a> WriteCtx<'a>

Source

pub fn new( conn: Arc<ClientConnection>, lun: u64, itt: Arc<AtomicU32>, cmd_sn: Arc<AtomicU32>, exp_stat_sn: Arc<AtomicU32>, cdb: [u8; 16], payload: impl Into<Vec<u8>>, ) -> Self

Creates a new WriteCtx for a SCSI Write operation.

Trait Implementations§

Source§

impl<'a> Debug for WriteCtx<'a>

Source§

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

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

impl<'ctx> StateMachine<WriteCtx<'ctx>, Transition<WriteStates, Result<(), Error>>> for Start

IssueCmd

  1. Send SCSI Command (WRITE) with no data in the command PDU.
  2. If payload is empty → go straight to waiting for SCSI Response. Otherwise → wait for R2T.
Source§

type StepResult<'a> = Pin<Box<dyn Future<Output = Transition<WriteStates, Result<(), Error>>> + Send + 'a>> where Self: 'a, WriteCtx<'ctx>: 'a

The future returned by the step method.
Source§

fn step<'a>(&'a self, ctx: &'a mut WriteCtx<'ctx>) -> Self::StepResult<'a>

Executes a single step of the state machine.
Source§

impl<'ctx> StateMachine<WriteCtx<'ctx>, Transition<WriteStates, Result<(), Error>>> for WaitR2T

WaitR2T

Await an R2T. Compute the data window (offset,len) safely, then move to SendWindow. We assume sequential windows.

Source§

type StepResult<'a> = Pin<Box<dyn Future<Output = Transition<WriteStates, Result<(), Error>>> + Send + 'a>> where Self: 'a, WriteCtx<'ctx>: 'a

The future returned by the step method.
Source§

fn step<'a>(&'a self, ctx: &'a mut WriteCtx<'ctx>) -> Self::StepResult<'a>

Executes a single step of the state machine.
Source§

impl<'ctx> StateMachine<WriteCtx<'ctx>, Transition<WriteStates, Result<(), Error>>> for Finish

WaitResp

Final step: wait for SCSI Command Response and validate GOOD status.

Source§

type StepResult<'a> = Pin<Box<dyn Future<Output = Transition<WriteStates, Result<(), Error>>> + Send + 'a>> where Self: 'a, WriteCtx<'ctx>: 'a

The future returned by the step method.
Source§

fn step<'a>(&'a self, ctx: &'a mut WriteCtx<'ctx>) -> Self::StepResult<'a>

Executes a single step of the state machine.
Source§

impl<'ctx> StateMachineCtx<WriteCtx<'ctx>, WriteOutcome> for WriteCtx<'ctx>

Source§

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

Executes the state machine to completion.

Auto Trait Implementations§

§

impl<'a> !Freeze for WriteCtx<'a>

§

impl<'a> !RefUnwindSafe for WriteCtx<'a>

§

impl<'a> !UnwindSafe for WriteCtx<'a>

§

impl<'a> Send for WriteCtx<'a>

§

impl<'a> Sync for WriteCtx<'a>

§

impl<'a> Unpin for WriteCtx<'a>

§

impl<'a> UnsafeUnpin for WriteCtx<'a>

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