Skip to main content

EngineClient

Trait EngineClient 

Source
pub trait EngineClient: Send {
    // Required methods
    fn start(&mut self) -> Result<()>;
    fn close(&mut self, abort: bool, timeout: bool);
    fn fd(&self) -> Option<RawFd>;
    fn events(&self) -> u32;
    fn is_delayable(&self) -> bool;
    fn is_registered(&self) -> bool;
    fn set_registered(&mut self, val: bool);
    fn autoclose(&self) -> bool;

    // Provided methods
    fn handle_read(&mut self) -> Result<usize> { ... }
    fn handle_write(&mut self) -> Result<usize> { ... }
}
Expand description

Trait for objects that can be managed by the Engine.

Clients are I/O objects (files, sockets, pipes) that the engine monitors for readability/writability and manages through their lifecycle.

Required Methods§

Source

fn start(&mut self) -> Result<()>

Start the client

Source

fn close(&mut self, abort: bool, timeout: bool)

Close the client

§Arguments
  • abort - Whether this is an abort close
  • timeout - Whether this is a timeout close
Source

fn fd(&self) -> Option<RawFd>

Get the file descriptor, if any

Source

fn events(&self) -> u32

Get the event interest bitmask (E_READ, E_WRITE, etc.)

Source

fn is_delayable(&self) -> bool

Check if this client can be delayed (batched)

Source

fn is_registered(&self) -> bool

Check if this client is currently registered with the engine

Source

fn set_registered(&mut self, val: bool)

Set the registered state

Source

fn autoclose(&self) -> bool

Check if this client should be autoclosed

Provided Methods§

Source

fn handle_read(&mut self) -> Result<usize>

Handle a read event on this client. Returns the number of bytes read, or 0 on EOF.

Source

fn handle_write(&mut self) -> Result<usize>

Handle a write event on this client. Returns the number of bytes written.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§