rfd
rfd copied to clipboard
sync API uses PathBuf but async API uses FileHandle
I noticed an inconsistency between the synchronous and asynchronous APIs. The synchronous APIs use PathBuf, but the async APIs use FileHandle. Is this inconsistency intention, and if so, why?
Yep it's very intentional because on wasm there is no concept of paths, you should just call read on the selected file, and therefore we needed an wrapper type that would provide async read(), functionality in all backends, it's easy to opt out of that by extracting the path, but in case you need to support every backend you are expected to use read() or extract JS File object out of it and handle it however you like
Okay. I think it would help to explain this in a comment.