manuel-woelker / rust-vfs

A virtual filesystem for Rust
Apache License 2.0
384 stars 44 forks source link

Feature: Seek + Write from VfsPath #35

Open jalcine opened 2 years ago

jalcine commented 2 years ago

I'm working on a union crate for this one and rusqlite that allows it to be used as the underlying storage. I have a branch that implements “random access”, which is vital for the SQLite implementation. I can see this being implemented in a way that would be optional for file systems that didn't support such an operation.

What are some things that are missing or could break here that'd prevent this from being made mainline? I could also see this being implemented as a trait for underlying VfsPathfile systems that also implement a means of producing random access files, so it'd fail at compile time.

(Originally published at: https://jacky.wtf/2022/7/lGgU)

manuel-woelker commented 2 years ago

Thanks for reaching out! Random access would indeed be a neat capability to have for a more complete feature set.

Ideally we should be catching random access on implementations that don't support it at compile time. On the other hand this might make ergonomics more complex, and make filesystems with "mixed" support more awkward to handle.

Another option might to hide seekability behind a feature, though that might also not be ideal from an ergonomics and discoverability perspective.

For now I think this looks like a good MVP. One thing that would be pretty neat is to have a basic test coverage of the update_file() function, to ensure that implementations behave in a predicatable way.

Would you be willing to create a pull request?

jalcine commented 2 years ago

I agree re: the ergonomics of things. I think I can experiment with extension-style traits to allow a conventional VfsPath "upgrade" to one that is seekable if the underlying VfsPath implements and able to support it.

That I can! I've opened it at @manuel-woelker/rust-vfs/pull/36

(Originally published at: https://jacky.wtf/2022/7/ZIUy)