Skip to main content

daemon

Function daemon 

Source
pub fn daemon<R, W, S, C, H, E>(
    channel: C,
    messages_handler: H,
    errors_handler: E,
) -> Daemon
where R: Read + Send + 'static, W: Write + Send + 'static, S: Serializer<R, W> + Send + 'static, C: OwnedChannel<R, W, S> + Send + 'static, H: Fn(S::Message) -> Option<S::Message> + Send + 'static, E: Fn(S::Error) -> bool + Send + 'static,
Expand description

Spawn new thread with a new Server struct which will listen to incoming messages in a loop, process them using the messages_handler and use errors_handler on any occuring errors.

If errors_handler returns true, then the thread will be closed.