[−][src]Function stateright::actor::spawn
pub fn spawn<A, E: Debug + 'static>(
serialize: fn(_: &A::Msg) -> Result<Vec<u8>, E>,
deserialize: fn(_: &[u8]) -> Result<A::Msg, E>,
actors: Vec<(impl Into<Id>, A)>
) -> Vec<JoinHandle<()>> where
A: 'static + Send + Actor,
A::Msg: Debug,
A::State: Debug,
Runs an actor, sending messages over UDP.
Example
use stateright::actor::{Id, spawn}; use std::net::{Ipv4Addr, SocketAddrV4}; let id1 = Id::from(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 3001)); let id2 = Id::from(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 3002)); spawn( serde_json::to_vec, |bytes| serde_json::from_slice(bytes), vec![ (id1, actor1), (id2, actor2), ]);