Skip to main content

Flow

Struct Flow 

Source
pub struct Flow { /* private fields */ }
Expand description

A submission to the Virtual Torus — the user-space equivalent of an io_uring SQE.

Flow wraps an I/O Operation along with user-provided data (user_data) that is returned verbatim in the corresponding Result when the operation completes. Applications submit Flows and later reap the matching Results, correlating them via user_data.

§Example

use tpt_torus_core::flow::Flow;
use tpt_torus_core::operation::Operation;

let flow = Flow::new(Operation::Read {
    fd: 0,
    buf: std::ptr::null_mut(),
    len: 0,
    offset: 0,
});
assert_eq!(flow.user_data(), 0);

Implementations§

Source§

impl Flow

Source

pub fn new(op: Operation) -> Self

Create a new Flow with the given operation and zero user data.

Source

pub fn with_user_data(op: Operation, user_data: u64) -> Self

Create a new Flow with user-provided data returned on completion.

The user_data value is opaque to the framework; it is stored with the flow and handed back unchanged in the corresponding Result so callers can correlate submissions with completions (e.g. as a request id or a pointer to a context struct).

Source

pub fn set_user_data(&mut self, data: u64) -> &mut Self

Attach arbitrary user data to this flow.

The value is returned unchanged in the corresponding Result.

Returns &mut Self for method chaining.

Source

pub fn user_data(&self) -> u64

Get the user data associated with this flow.

Source

pub fn operation(&self) -> &Operation

Access the inner operation.

Source

pub fn into_operation(self) -> Operation

Consume the flow, returning the inner operation.

Auto Trait Implementations§

§

impl !Send for Flow

§

impl !Sync for Flow

§

impl Freeze for Flow

§

impl RefUnwindSafe for Flow

§

impl Unpin for Flow

§

impl UnsafeUnpin for Flow

§

impl UnwindSafe for Flow

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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