Struct Proactor
pub struct Proactor { /* private fields */ }Expand description
Low-level actions of completion-based IO. It owns the operations to keep the driver safe.
Implementations§
§impl Proactor
impl Proactor
pub fn builder() -> ProactorBuilder
pub fn builder() -> ProactorBuilder
Create ProactorBuilder to config the proactor.
pub fn default_extra(&self) -> Extra
pub fn default_extra(&self) -> Extra
Get a default Extra for underlying driver.
pub fn driver_type(&self) -> DriverType
pub fn driver_type(&self) -> DriverType
The current driver type.
pub fn attach(&mut self, fd: *mut c_void) -> Result<(), Error>
pub fn attach(&mut self, fd: *mut c_void) -> Result<(), Error>
Attach an fd to the driver.
§Platform specific
- IOCP: it will be attached to the completion port. An fd could only be
attached to one driver, and could only be attached once, even if you
try_cloneit. - io-uring & polling: it will do nothing but return
Ok(()).
pub fn cancel<T>(&mut self, key: Key<T>) -> Option<BufResult<usize, T>>where
T: OpCode,
pub fn cancel<T>(&mut self, key: Key<T>) -> Option<BufResult<usize, T>>where
T: OpCode,
Cancel an operation with the pushed Key.
The cancellation is not reliable. The underlying operation may continue,
but just don’t return from Proactor::poll.
pub fn push<T>(&mut self, op: T) -> PushEntry<Key<T>, BufResult<usize, T>>where
T: OpCode + 'static,
pub fn push<T>(&mut self, op: T) -> PushEntry<Key<T>, BufResult<usize, T>>where
T: OpCode + 'static,
Push an operation into the driver, and return the unique key Key,
associated with it.
pub fn push_with_extra<T>(
&mut self,
op: T,
extra: Extra,
) -> PushEntry<Key<T>, BufResult<usize, T>>where
T: OpCode + 'static,
pub fn push_with_extra<T>(
&mut self,
op: T,
extra: Extra,
) -> PushEntry<Key<T>, BufResult<usize, T>>where
T: OpCode + 'static,
pub fn poll(&mut self, timeout: Option<Duration>) -> Result<(), Error>
pub fn poll(&mut self, timeout: Option<Duration>) -> Result<(), Error>
Poll the driver and get completed entries.
You need to call Proactor::pop to get the pushed
operations.
pub fn pop<T>(&mut self, key: Key<T>) -> PushEntry<Key<T>, BufResult<usize, T>>
pub fn pop<T>(&mut self, key: Key<T>) -> PushEntry<Key<T>, BufResult<usize, T>>
Get the pushed operations from the completion entries.
§Panics
This function will panic if the requested operation has not been completed.
pub fn pop_with_extra<T>(
&mut self,
key: Key<T>,
) -> PushEntry<Key<T>, (BufResult<usize, T>, Extra)>
pub fn pop_with_extra<T>( &mut self, key: Key<T>, ) -> PushEntry<Key<T>, (BufResult<usize, T>, Extra)>
pub fn update_waker<T>(&mut self, op: &mut Key<T>, waker: &Waker)
pub fn update_waker<T>(&mut self, op: &mut Key<T>, waker: &Waker)
Update the waker of the specified op.
pub fn create_buffer_pool(
&mut self,
buffer_len: u16,
buffer_size: usize,
) -> Result<BufferPool, Error>
pub fn create_buffer_pool( &mut self, buffer_len: u16, buffer_size: usize, ) -> Result<BufferPool, Error>
Create buffer pool with given buffer_size and buffer_len
§Notes
If buffer_len is not a power of 2, it will be rounded up with
u16::next_power_of_two.
pub unsafe fn release_buffer_pool(
&mut self,
buffer_pool: BufferPool,
) -> Result<(), Error>
pub unsafe fn release_buffer_pool( &mut self, buffer_pool: BufferPool, ) -> Result<(), Error>
Release the buffer pool
§Safety
Caller must make sure to release the buffer pool with the correct driver, i.e., the one they created the buffer pool with.
pub fn register_personality(&self) -> Result<u16, Error>
pub fn register_personality(&self) -> Result<u16, Error>
Register a new personality in io-uring driver.
Returns the personality id, which can be used with
Extra::set_personality to set the personality for an operation.
This only works on io_uring driver. It will return an Unsupported
error on other drivers. See Submitter::register_personality for
more.
pub fn unregister_personality(&self, personality: u16) -> Result<(), Error>
pub fn unregister_personality(&self, personality: u16) -> Result<(), Error>
Unregister the given personality in io-uring driver.
This only works on io_uring driver. It will return an Unsupported
error on other drivers. See Submitter::unregister_personality for
more.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Proactor
impl RefUnwindSafe for Proactor
impl Send for Proactor
impl Sync for Proactor
impl Unpin for Proactor
impl UnwindSafe for Proactor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more