Skip to main content

IoContext

Struct IoContext 

Source
pub struct IoContext<S: IoState, O: Origin = Solicited> {
    pub reply: ReplyHeader,
    request: O::Request,
    state: S,
}
Expand description

The server’s work item for one request (or one server event). Owns the reply header and — while Solicited — the parsed request; parameterized by the lifecycle state S and origin O.

Fields§

§reply: ReplyHeader

Header the eventual reply is framed with.

§request: O::Request

Owned request payload for this origin (SmbRequest for Solicited, () otherwise). Accessed only through the state-appropriate methods.

§state: S

Lifecycle state value (a ZST for data-less states; carries data for Pending).

Implementations§

Source§

impl IoContext<Accepted, Solicited>

Source

pub fn accept(reply: ReplyHeader, request: SmbRequest) -> Self

Accept a parsed request for processing; the SmbRequest is moved in and owned by the context from here on.

Source

pub(crate) fn split(self) -> (IoContext<Accepted, Bare>, SmbRequest)

Split the request out to hand it to its concrete Command handler; the context keeps the reply header and becomes request-neutral (Bare).

Source§

impl IoContext<Accepted, Unsolicited>

Source

pub fn from_event(reply: ReplyHeader) -> Self

Build a request-less context for a server-initiated response.

Source§

impl<O: Origin> IoContext<Accepted, O>

Source

pub fn respond(self, status: Status, body: Vec<u8>) -> SmbResponse

Produce the terminal reply, consuming the context (the request payload is dropped). Reachable in the Accepted state for any origin.

Source§

impl IoContext<Accepted, Bare>

Source

pub fn defer(self, async_id: u64) -> IoContext<Pending, Bare>

Defer this request: park it as Pending so an async worker owns it and completes it later; the reader loop is never blocked.

Source§

impl IoContext<Pending, Bare>

Source

pub fn async_id(&self) -> u64

The async correlation id this deferred op was parked under.

Source

pub fn interim(&self, status: Status, body: Vec<u8>) -> SmbResponse

Build the immediate interim reply for this deferred op without consuming the parked context ([MS-SMB2] §3.3.4.2). The worker still owns self and completes it later.

Source

pub fn complete(self, status: Status, body: Vec<u8>) -> SmbResponse

Complete a deferred op with its final reply, consuming the parked context. Only callable in the Pending state, so a request cannot be completed unless it was actually deferred.

Trait Implementations§

Source§

impl<S: Debug + IoState, O: Debug + Origin> Debug for IoContext<S, O>
where O::Request: Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S, O> Freeze for IoContext<S, O>
where <O as Origin>::Request: Freeze, S: Freeze,

§

impl<S, O> RefUnwindSafe for IoContext<S, O>

§

impl<S, O> Send for IoContext<S, O>
where <O as Origin>::Request: Send, S: Send,

§

impl<S, O> Sync for IoContext<S, O>
where <O as Origin>::Request: Sync, S: Sync,

§

impl<S, O> Unpin for IoContext<S, O>
where <O as Origin>::Request: Unpin, S: Unpin,

§

impl<S, O> UnsafeUnpin for IoContext<S, O>

§

impl<S, O> UnwindSafe for IoContext<S, O>
where <O as Origin>::Request: UnwindSafe, S: 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
§

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

§

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.

§

impl<T> Instrument for T

§

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

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

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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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