We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fc6fa9a commit aefb562Copy full SHA for aefb562
src/commands/logs.rs
@@ -40,11 +40,19 @@ pub fn cmd_logs(args: &LogsArgs) -> Result<()> {
40
}
41
42
43
+// Given the binary stream so far, read the first COBS frame and return the rest of bytes.
44
fn advance(chunk: &[u8]) -> (Vec<u8>, &[u8]) {
45
+ // Skip the partial frame: all bytes before the separator.
46
+ let maybe = chunk.iter().enumerate().find(|(_, b)| **b == 0x00);
47
+ let Some((start, _)) = maybe else {
48
+ return (Vec::new(), chunk);
49
+ };
50
+ let chunk = &chunk[start..];
51
+
52
let max_len = chunk.len();
53
let mut out_buf = vec![0; max_len];
54
let mut dec = cobs::CobsDecoder::new(&mut out_buf);
- match dec.push(chunk) {
55
+ match dec.push(&chunk[1..]) {
56
Ok(Some((n_out, n_in))) => {
57
let msg = Vec::from(&out_buf[..n_out]);
58
(msg, &chunk[n_in..])
0 commit comments