[−][src]Trait kompact::prelude::ActorRaw
The base trait for all actors
This trait handles raw message envelopes, without any unpacking or other convenient syntactic sugars.
Usually it's better to use the unwrapped functions in Actor, but this can be more efficient at times, for example when the content of the envelope isn't actually accessed in the component.
Example
use kompact::prelude::*; #[derive(ComponentDefinition)] struct RawActor { ctx: ComponentContext<Self> } ignore_control!(RawActor); impl ActorRaw for RawActor { type Message = (); fn receive(&mut self, env: MsgEnvelope<Self::Message>) -> () { match env { MsgEnvelope::Typed(m) => info!(self.log(), "Got a local message: {:?}", m), MsgEnvelope::Net(nm) => info!(self.log(), "Got a network message: {:?}", nm), } } }
Associated Types
type Message: MessageBounds
The type of local messages the actor accepts
Required methods
fn receive(&mut self, env: MsgEnvelope<Self::Message>)
Handle an incoming message
Incoming messages can either be local, in which case they are of type
Self::Message
(wrapped into a MsgEnvelope),
or they are coming from the network, in which case they of type
NetMessage (again wrapped into a MsgEnvelope).
Note
Remember that components usually run on a shared thread pool, so, just like for handle implementations, you shouldn't ever block in this method unless you know what you are doing.
Implementors
impl ActorRaw for TestComponent1
[src]
impl ActorRaw for TestComponent2
[src]
impl<A, M: MessageBounds> ActorRaw for A where
A: Actor<Message = M>,
[src]
A: Actor<Message = M>,