rfd icon indicating copy to clipboard operation
rfd copied to clipboard

sync API uses PathBuf but async API uses FileHandle

Open Be-ing opened this issue 3 years ago • 2 comments

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?

Be-ing avatar Jan 18 '22 02:01 Be-ing

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

PolyMeilex avatar Jan 18 '22 10:01 PolyMeilex

Okay. I think it would help to explain this in a comment.

Be-ing avatar Jan 18 '22 16:01 Be-ing