Skip to content

Commit

Permalink
Merge pull request #528 from uuid-rs/ci/more-embedded
Browse files Browse the repository at this point in the history
check more features in no-std
  • Loading branch information
KodrAus authored Aug 16, 2021
2 parents d25b287 + 8701d0e commit e51f80a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: build
args: -Z avoid-dev-deps --target thumbv6m-none-eabi --no-default-features
args: -Z avoid-dev-deps --target thumbv6m-none-eabi --no-default-features --features "v1 v3 v5 serde"

nodeps:
name: Build / No deps
Expand Down
9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ repository = "uuid-rs/uuid"

[dependencies.getrandom]
optional = true
version = "0.2.0"
version = "0.2"

[dependencies.atomic]
default-features = false
optional = true
version = "0.5"

[dependencies.md-5]
default-features = false
Expand Down Expand Up @@ -98,7 +103,7 @@ default = ["std"]
guid = ["winapi"]
std = []
stdweb = ["getrandom", "getrandom/js"]
v1 = []
v1 = ["atomic"]
v3 = ["md-5"]
v4 = ["getrandom"]
v5 = ["sha-1"]
Expand Down
36 changes: 30 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@
//! * `serde` - adds the ability to serialize and deserialize a UUID using the
//! `serde` crate.
//!
//! For WebAssembly, enable one of the following features depending
//! on your JavaScript interop toolchain of choice:
//!
//! * `stdweb` - for [`stdweb`] combined with [`cargo-web`]
//! * `wasm-bindgen` - for [`wasm-bindgen`]
//!
//! By default, `uuid` can be depended on with:
//!
//! ```toml
Expand All @@ -70,6 +64,35 @@
//! uuid = { version = "0.8", default-features = false }
//! ```
//!
//! # Building for other targets
//!
//! ## WebAssembly
//!
//! For WebAssembly, enable one of the following features depending
//! on your JavaScript interop toolchain of choice:
//!
//! * `stdweb` - for [`stdweb`] combined with [`cargo-web`]
//! * `wasm-bindgen` - for [`wasm-bindgen`]
//!
//! ## Embedded
//!
//! For embedded targets without the standard library, you'll need to
//! disable default features when building `uuid`:
//!
//! ```toml
//! [dependencies]
//! uuid = { version = "0.8", default-features = false }
//! ```
//!
//! Some additional features are supported in no-std environments:
//!
//! * `v1`, `v3`, and `v5`
//! * `serde`
//!
//! If you need to use `v4` in a no-std environment, you'll need to
//! follow [`getrandom`'s docs] on configuring a source of randomness
//! on unsupported targets.
//!
//! # Examples
//!
//! To parse a UUID given in the simple format and print it as a urn:
Expand Down Expand Up @@ -143,6 +166,7 @@
//! [`Uuid::new_v5`]: struct.Uuid.html#method.new_v5
//! [`v1::ClockSequence`]: v1/trait.ClockSequence.html
//! [`v1::Context`]: v1/struct.Context.html
//! [`getrandom`'s docs]: https://docs.rs/getrandom

#![no_std]
#![deny(missing_debug_implementations, missing_docs)]
Expand Down
6 changes: 3 additions & 3 deletions src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Note that you need feature `v1` in order to use these features.

use crate::prelude::*;
use core::sync::atomic;
use atomic::Atomic;

/// The number of 100 ns ticks between the UUID epoch
/// `1582-10-15 00:00:00` and the Unix epoch `1970-01-01 00:00:00`.
Expand All @@ -13,7 +13,7 @@ const UUID_TICKS_BETWEEN_EPOCHS: u64 = 0x01B2_1DD2_1381_4000;
/// process-wide uniqueness.
#[derive(Debug)]
pub struct Context {
count: atomic::AtomicUsize,
count: Atomic<usize>,
}

/// Stores the number of nanoseconds from an epoch and a counter for ensuring
Expand Down Expand Up @@ -265,7 +265,7 @@ impl Context {
/// process.
pub const fn new(count: u16) -> Self {
Self {
count: atomic::AtomicUsize::new(count as usize),
count: Atomic::new(count as usize),
}
}
}
Expand Down

0 comments on commit e51f80a

Please sign in to comment.