-
SummaryI'm super new to Rust and WebAssembly so I apologize if this a basic question. I am attempting to write a simple program that reads and writes to the OPFS. All of the work is happening inside a Worker Thread. I get a Window from the WorkerGlobalScope, get the navigator, then I open a new file eventually getting a FileSystemSyncAccessHandle. From there I write out a bunch of bytes to the file and close it. Before I close it I check the size and it says it has content. I then try to use the FileSystemDirectoryHandle entries method to iterate over the list of files in the base folder. The compiler complains until I do this: Additional Details`
` |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I believe what you are looking for is Unfortunately this method is currently not available in extern "C" {
#[wasm_bindgen(extends = FileSystemDirectoryHandle)]
type FileSystemDirectoryHandleExt;
#[wasm_bindgen(method)]
fn entries(this: &FileSystemDirectoryHandleExt) -> js_sys::AsyncIterator;
}
let dir: FileSystemDirectoryHandle = dir;
let dir: FileSystemDirectoryHandleExt = dir.unchecked_into();
let entries = dir.entires();
while Ok(entry) = entries.next() {
let entry = JsFuture::from(entry).await;
// do your thing
} |
Beta Was this translation helpful? Give feedback.
I believe what you are looking for is
FileSystemDirectoryHandle.entries()
, which is not the same asObject.entries()
.Unfortunately this method is currently not available in
web-sys
, but it was added in #3962, so you have to wait for the new release, depend on the master branch or add bindings yourself: