fn read_message<R>(reader: &mut R) -> Result<Option<Vec<u8>>>where
    R: Read + BufRead,