/// Simple helper to send all available lines through whenever processing a read
/// event.
Simple helper to send all available lines through whenever processing a read
event.
Simple helper to send all available lines through whenever processing a read event .
pub fn extend_and_send_lines_through<E>(
    logger: &Logger,
    snd: &Sender<E>,
    str2e: impl Fn(String) -> E,
) -> impl Fn(&[u8], &mut LineBuffer) {
    let snd = snd.clone();
    let logger = logger.clone();
    move |us, buf| {
        buf.extend_from_slice(us);
        while let Some(line) = buf.read_line() {
            if let Err(e) = snd.send(str2e(line)) {
                warn!(logger, "Couldn't send: {:?}", e);
            }
        }
    }
}
pub fn extend_and_send_lines_through < E > ( logger : & Logger , snd : & Sender < E > , str2e : impl Fn ( String ) -> E , ) -> impl Fn ( & [ u8 ] , & mut LineBuffer ) { let snd = snd . clone ( ) ; let logger = logger . clone ( ) ; move | us , buf | { buf . extend_from_slice ( us ) ; while let Some ( line ) = buf . read_line ( ) { if let Err ( e ) = snd . send ( str2e ( line ) ) { warn ! ( logger " " e ) ; } } } }
Simple helper to send all available lines through whenever processing a read
event.
Simple helper to send all available lines through whenever processing a read event .
logger
&Logger
snd
&Sender<E>
str2e
impl Fn(String) -> E