Untitled

mail@pastecode.io avatar
unknown
rust
22 days ago
906 B
2
Indexable
Never
            'outer: loop {
                let cb_read = port.read(&mut buffer)?;
                if cb_read == 0 {
                    return Err(SendError::BrokenPipe);
                }

                let mut iter = self.parser.consume(&buffer[..cb_read]);
                'inner: loop {
                    let Some(raw_packet) = iter.next() else {
                        break 'inner;
                    };

                    let is_processed = match raw_packet {
                        Ok(packet) => {
                            handler(packet)?
                        }
                        Err(cause) => {
                            warn!("Malformed packet: {}", cause);
                            false
                        }
                    };

                    if is_processed {
                        break 'outer;
                    }
                }
            }
Leave a Comment