Trait rotor_capnp::Endpoint
[−]
[src]
pub trait Endpoint: Sized { type Context; type Socket: StreamSocket; type Seed; fn create(
seed: Self::Seed,
sock: &mut Self::Socket,
scope: &mut Scope<Self::Context>
) -> Action<Self>; fn message_received(
self,
message: &MessageReader,
output: MessageWriter,
scope: &mut Scope<Self::Context>
) -> Action<Self>; fn message_flushed(
self,
output: MessageWriter,
scope: &mut Scope<Self::Context>
) -> Action<Self>; fn recv_timeout(&self, scope: &mut Scope<Self::Context>) -> Duration; fn send_timeout(&self, scope: &mut Scope<Self::Context>) -> Duration; fn timeout(
self,
state: ConnectionState,
output: MessageWriter,
scope: &mut Scope<Self::Context>
) -> Action<Self>; fn wakeup(&self, scope: &mut Scope<Self::Context>) -> Action<Self>; fn exception(self, err: Error, scope: &mut Scope<Self::Context>); fn reader_options(&self, _scope: &mut Scope<Self::Context>) -> ReaderOptions { ... } fn idle_timeout(&self, _scope: &mut Scope<Self::Context>) -> Duration { ... } }
A handler for receiving and sending Cap'n Proto messages.
Currently this is used by both client side and server side of the connection. Client specific abstractions might be added in the future.
Associated Types
type Context
Context shared between transitions of the state machine.
type Socket: StreamSocket
Type of the underlying socket.
type Seed
Seed for initializing the state machine.
Required Methods
fn create(
seed: Self::Seed,
sock: &mut Self::Socket,
scope: &mut Scope<Self::Context>
) -> Action<Self>
seed: Self::Seed,
sock: &mut Self::Socket,
scope: &mut Scope<Self::Context>
) -> Action<Self>
A new connection has been established.
fn message_received(
self,
message: &MessageReader,
output: MessageWriter,
scope: &mut Scope<Self::Context>
) -> Action<Self>
self,
message: &MessageReader,
output: MessageWriter,
scope: &mut Scope<Self::Context>
) -> Action<Self>
A new message has been received.
fn message_flushed(
self,
output: MessageWriter,
scope: &mut Scope<Self::Context>
) -> Action<Self>
self,
output: MessageWriter,
scope: &mut Scope<Self::Context>
) -> Action<Self>
All outgoing messages have been flushed.
fn recv_timeout(&self, scope: &mut Scope<Self::Context>) -> Duration
Timeout for reading a message.
fn send_timeout(&self, scope: &mut Scope<Self::Context>) -> Duration
Timeout for sending a message.
fn timeout(
self,
state: ConnectionState,
output: MessageWriter,
scope: &mut Scope<Self::Context>
) -> Action<Self>
self,
state: ConnectionState,
output: MessageWriter,
scope: &mut Scope<Self::Context>
) -> Action<Self>
Timeout expired during the state
.
fn wakeup(&self, scope: &mut Scope<Self::Context>) -> Action<Self>
The state machine has been woken up.
fn exception(self, err: Error, scope: &mut Scope<Self::Context>)
Connection will be closed after this.
Provided Methods
fn reader_options(&self, _scope: &mut Scope<Self::Context>) -> ReaderOptions
Options for the Cap'n Proto message reader.
fn idle_timeout(&self, _scope: &mut Scope<Self::Context>) -> Duration
Timeout for an idle connection. By default it's 120 seconds.