January 2019
Intermediate to advanced
520 pages
14h 32m
English
We will start with updating the message. Add a RepeaterUpdate struct that wraps a NewComment type:
#[derive(Clone)]pub struct RepeaterUpdate(pub NewComment);
As you can see, we also derived the Clone trait, because we need to clone this message to resend it to multiple subscribers. NewComment also has to be cloneable now.
Let's implement the Message trait for the RepeaterUpdate struct. We will use an empty type for the Result associated type, because we don't care about the delivery of these messages:
impl Message for RepeaterUpdate { type Result = ();}
Now, we can implement a Handler for the RepeaterUpdate message type:
impl Handler<RepeaterUpdate> for RepeaterActor { type Result = (); fn handle(&mut self, msg: RepeaterUpdate, ...Read now
Unlock full access