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
impl Flow
Sourcepub fn new(op: Operation) -> Self
pub fn new(op: Operation) -> Self
Create a new Flow with the given operation and zero user data.
Sourcepub fn with_user_data(op: Operation, user_data: u64) -> Self
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).
Sourcepub fn set_user_data(&mut self, data: u64) -> &mut Self
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.
Sourcepub fn into_operation(self) -> Operation
pub fn into_operation(self) -> Operation
Consume the flow, returning the inner operation.