From 3b7d2cc86be2d66cc8573207e8ebe1a78791d807 Mon Sep 17 00:00:00 2001 From: Louis Capitanchik <contact@louiscap.co> Date: Wed, 4 Jan 2023 15:35:07 +0000 Subject: [PATCH] Update Crate metadata --- Cargo.toml | 4 +++- README.md | 2 +- src/lib.rs | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9e2d4d4..96bbc3f 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 9a60646..6134444 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 97419ad..8e11342 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")] -- GitLab