diff --git a/Cargo.toml b/Cargo.toml index 9e2d4d43b3056937215807a625f3c9d64975ac06..96bbc3fd903386fad76aaf9bc57c48b70307687c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "web_instant" -version = "0.2.0" +version = "0.2.1" edition = "2021" description = "Cross platform impl of Instant" authors = [ @@ -8,6 +8,8 @@ authors = [ ] repository = "https://lab.lcr.gr/microhacks/web-instant" homepage = "https://lab.lcr.gr/microhacks/web-instant" +documentation = "https://docs.rs/web_instant" + license = "Apache-2.0" [target."wasm32-unknown-unknown".dependencies] diff --git a/README.md b/README.md index 9a6064623238024c8a7c9ff7e2e3b2e278ad1d7b..61344448842e130471753aa7f943c2200cdb34b2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Web Instant -Provides `Spot`, a version of `Instant` that works both on desktop and the web. On desktop, the internal representation uses `std::time::Instant`. On the web, the internal representation is an `f64`, +Provides `Spot`, a version of `Instant` that works both in environments that support `Instant` and `wasm` family targets. On desktop, the internal representation uses `std::time::Instant`. On the web, the internal representation is an `f64`, and uses `js_sys::Date` methods to cover functinality where required All the methods on `Instant` are implemented for `Spot`, so you can just replace uses of `std::time::Instant` with `web_instant::Spot` diff --git a/src/lib.rs b/src/lib.rs index 97419ad175b9c13c4a136c09fe793dfd635aff71..8e1134221f943d8d39e83a63e7252ddff163a22a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,26 @@ +//! # Web Instant +//! +//! Provides `Spot`, a version of `Instant` that works both in environments that support `Instant` and `wasm` family targets. On desktop, the internal representation uses `std::time::Instant`. On the web, the internal representation is an `f64`, +//! and uses `js_sys::Date` methods to cover functinality where required +//! +//! All the methods on `Instant` are implemented for `Spot`, so you can just replace uses of `std::time::Instant` with `web_instant::Spot` +//! +//! ## Install +//! +//! `cargo add web_instant` +//! +//! ## Usage +//! +//! ```rust +//! use web_instant::Spot; +//! use std::time::Duration; +//! +//! fn my_cross_platform_timer(last_time: Spot) { +//! let time_diff: Duration = Spot::now() - last_time; +//! println!("It has been {} seconds", time_diff.as_secs()); +//! } +//! ``` + #[cfg(not(target_family = "wasm"))] mod instant_desktop; #[cfg(target_family = "wasm")]