interlink

Module msg

Source
Expand description

§Messages

Messages are used to communicate with services. Messages are handled by Handler’s on services and must respond with a specific message type. The default derived message response type is the unit type. When handling a value you must choose a response type for how you intent to create the response value. See the different types below:

§Response Types

  • () Unit response type. This type responds with a empty value allowing you to return nothing from a handler
  • Mr Message response type. This is for when you are synchronously responding to a message.
  • Fr Future response type. This is for responding with a value that is created by awaiting a future. The future is spawned into a new tokio task
  • Sfr Service future response type. This is for when the response depends on awaiting a future that requires a mutable borrow over the service and/or the service context

§Messages

Things that can be sent to services as messages must implement the Message trait. This trait can also be derived using the following derive macro.

use interlink::prelude::*;

#[derive(Message)]
struct MyMessage {
    value: String,
}

Without specifying the response type in the above message it will default to the () unit response type. To specify the response type you can use the syntax below

use interlink::prelude::*;

#[derive(Message)]
#[msg(rtype = "String")]
struct MyMessage {
    value: String,
}

The rtype portion specifies the type of the response value.

Structs§

Fr
Future Response
Mr
Message Response
Sfr
Service Future Response

Enums§

ErrorAction
Actions that can be taken after handling an error.

Traits§

ErrorHandler
Handler for accepting streams of messages for a service from streams attached to the service
Handler
Handler implementation for allowing a service to handle a specific message type
Message
Message type implemented by structures that can be passed around as messages through envelopes.
ResponseHandler
Handler implementation for handling what happens with a response value
StreamHandler
Handler for accepting streams of messages for a service from streams attached to the service see attach_stream on ServiceContext

Type Aliases§

BoxFuture
Type alias for a future that is pinned and boxed with a specific return type (T) and lifetime (’a)