vi / rust-nbd

Rust library for NBD (network block device) protocol.
26 stars 6 forks source link

impl FileExt for NbdClient #3

Open asomers opened 4 years ago

asomers commented 4 years ago

Would it be possible to implement FileExt for NbdClient? That way consumers could do a single read_exact_at instead of a seek followed by read_exact.

vi commented 4 years ago

Probably. Do you mean both std::os::windows::fs::FileExt and std::os::unix::fs::FileExt or just one of them? Maybe there is some crate with platform-independent abstraction of read_at?

A pull request is welcome.

vi commented 4 years ago

Maybe better implement positioned_io::ReadAt or buffered_offset_reader::OffsetReadMut (or both)?

asomers commented 4 years ago

Well, I was only thinking about unix. Does anybody even use NBD on Windows?

vi commented 4 years ago

Does anybody even use NBD on Windows?

I remember trying to use in-memory NBD server running on Windows as a swap-file on Linux.

(Nothing good happened from that attempt although)


I've published read_write_at that intents to be a central place for "read/write with offset" abstraction. I'm going to implement read_write_at::ReadWriteAtMut for NBD client and maybe integrate it somehow with the server as well.

Maybe there will be a wrapper for FileExt as well in read_write_at v0.2.