BytesCursor abstraction in FuseDevWriter - #221
Conversation
|
somehow CI is not running. Let me close and reopen to trigger it. |
| fn test_extend_from_slice() { | ||
| let mut array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; | ||
| let mut b = BytesCursor::new(&mut array, 3); | ||
| b.extend_from_slice(&[b'a', b'b']); |
There was a problem hiding this comment.
Nit: clippy (byte_char_slices) flags this and CI runs with -Dwarnings:
b.extend_from_slice(b"ab");
| Ok(cnt) | ||
| } else { | ||
| Self::do_write(self.fd, &self.buf[..cnt]) | ||
| Self::do_write(self.fd, &self.buf.slice_mut()[..cnt]) |
There was a problem hiding this comment.
Nit: the sibling call site in write_from uses self.buf.written()[..cnt]. Both are equivalent here (position was 0 before the write), but written()[..cnt] expresses the intent more clearly — could use it here too for consistency?
Self::do_write(self.fd, &self.buf.written()[..cnt])
| /// device write operation. | ||
| /// 3. Concurrency, caller should not write to the writer concurrently. | ||
| #[derive(Debug, PartialEq, Eq)] | ||
| #[derive(Debug)] |
There was a problem hiding this comment.
Just a heads-up: FuseDevWriter is a public type, so removing PartialEq/Eq is technically an API-breaking change. I checked nothing in this repo relies on it, but it's probably worth a one-liner in the changelog.
Or we may keep it as is.
| @@ -0,0 +1,110 @@ | |||
| use crate::transport::Error; | |||
There was a problem hiding this comment.
Please help to add copyright header?
FuseDevWriter.buffield isManuallyDrop<Vec<u8>>, but actually it is a pair of&mut [u8]space and position.Express this logic more explicitly with
Because:
&mutpointers). It may be not an issue, but with this change is much more clear