Message

The counting actor expects a message with a string, and we'll add the following struct:

pub struct Count(pub String);

impl Message for Count {
type Result = Value;
}

The Count struct has a single filed with the String type and implements the Message trait of the Actix framework. This implementation allows us to send Count instances using the address of the actor.

The Message trait needs type of associated type Result. This value will be returned after the message is processed. We'll return a counter value for the provided string.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.19.185