Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/whizsid/wasmtimer-rs
std::time, tokio::time, tokio_util::time Replacement for WASM targets.
https://github.com/whizsid/wasmtimer-rs
async-await browser hacktoberfest rust timer tokio wasm webassembly
Last synced: about 1 hour ago
JSON representation
std::time, tokio::time, tokio_util::time Replacement for WASM targets.
- Host: GitHub
- URL: https://github.com/whizsid/wasmtimer-rs
- Owner: whizsid
- License: mit
- Created: 2023-01-08T04:09:38.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-10-17T18:23:23.000Z (27 days ago)
- Last Synced: 2024-10-30T21:05:31.649Z (14 days ago)
- Topics: async-await, browser, hacktoberfest, rust, timer, tokio, wasm, webassembly
- Language: Rust
- Homepage:
- Size: 105 KB
- Stars: 15
- Watchers: 2
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# wasmtimer-rs
An implementation of `time` based functionalities from `std::time`, `tokio::time`,
`tokio_util::time` for WASM targets. This crate tries to closely
replicate above APIs. Users only have to change their `use` scripts by
using a `cfg` macro.```rust
#[cfg(not(target_family="wasm"))]
use tokio::time::*;
#[cfg(target_family="wasm")]
use wasmtimer::tokio::*;
```Check the [API Documentation](https://docs.rs/wasmtimer) for more
details.## Story
Core idea and core modules in `src/timer` folder were copied from
[this](https://github.com/tomaka/wasm-timer) crate. This crate is
abandoned now due to lack of maintainability. I've hard forked it,
added some additional features and released to use for
[this](https://github.com/google/tarpc/pull/388) PR.## `tokio::time` vs `wasmtimer`
- `wasmtimer` is only running on WASM browser targets and not using any
`tokio` feature as a dependency.
- This timer crate not supporting
[Auto-advance](https://docs.rs/tokio/latest/tokio/time/fn.pause.html#auto-advance)
like in the tokio crate. Because we can not track the background
tasks(`Promise`) in browser scope. If we implemented such without caring
about background tasks, then this implementation will not match with the
tokio's original implementation.## Features
- Serde Support (`serde` feature flag)
- Worker and NodeJS Support
- Test Utilities