Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Extend tokio fs to be compatible with native and wasm

NotificationsYou must be signed in to change notification settings

utooland/tokio-fs-ext

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crates.ioDocs.rs

Tokio-fs-ext is a Rust library that provides atokio::fs compatible API for both native and WebAssembly environments on web browsers.

Overview

The standardtokio::fs module in the Tokio runtime is a powerful tool for asynchronous file system operations. However, it relies on blockingsyscalls an I/O operations that are executed on a dedicated thread pool. This design is not suitable for WebAssembly environments where threading and direct file system access are restricted.

This library aims to bridge that gap by offering an API that is compatible withtokio::fs but works seamlessly in WebAssembly. It provides a consistent interface for file system operations, regardless of the target platform.

Features

  • Atokio::fs-like API.
  • Re-exporttokio::fs on native platforms, and use implementations byOPFS onwasm32-unknown-unknown platform.
  • Implementedfutures::io::traits.
  • Asynchronous file operations for non-blocking applications.

Usage

use tokio_fs_extas fs;use std::io;use futures::io::AsyncReadExt;asyncfnfoo() -> io::Result<()>{    fs::write("hello.txt","Hello").await?;{letmut file = fs::File::open("hello.txt").await?;letmut vec =Vec::new();        file.read_to_end(&mut vec).await?;}    fs::remove_file("hello.txt").await?;Ok(())}

Clarification

Contributing

Testing

# test nativecargotest# test wasmbrew install --cask chromedrivercargotest --target wasm32-unknown-unknown# test wasm in interactive modebrew install wasm-packwasm-packtest --chrome

About

Extend tokio fs to be compatible with native and wasm

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors3

  •  
  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp