Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop uuid dependency to simplify wasm use #365

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,19 @@ jobs:

- name: check typos
uses: crate-ci/[email protected]

# We use `cargo build` here because `cargo check` doesn't pick up all
# warnings / errors. Notably, it misses `arithmetic_overflow`.
check-wasm:
name: cargo check wasm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: wasm32-unknown-unknown

- name: build fontdrasil for wasm32-unknown-unknown
run: cargo build --target wasm32-unknown-unknown
7 changes: 1 addition & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "norad"
version = "0.14.2"
version = "0.15.2"
authors = ["Colin Rofls <[email protected]>", "Nikolaus Waxweiler <[email protected]>"]
license = "MIT OR Apache-2.0"
edition = "2021"
Expand All @@ -22,11 +22,6 @@ default = []
kurbo = ["dep:kurbo"]
rayon = ["dep:rayon"]

[target.'cfg(not(target_family = "wasm"))'.dependencies]
uuid = { version = "1.2", features = ["v4"] }
[target.'cfg(target_family = "wasm")'.dependencies]
uuid = { version = "1.2", features = ["v4", "js"] }

[dependencies]
plist = { version = "1.4.1", features = ["serde"] }
serde = { version = "1.0", features = ["rc", "derive"] }
Expand Down
20 changes: 4 additions & 16 deletions src/glyph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,11 +486,8 @@ impl Anchor {
}

/// Replaces the actual lib by the lib given in parameter, returning the old
/// lib if present. Sets a new UUID v4 identifier if none is set already.
/// lib if present.
pub fn replace_lib(&mut self, lib: Plist) -> Option<Plist> {
if self.identifier.is_none() {
self.identifier.replace(Identifier::from_uuidv4());
}
self.lib.replace(lib)
}

Expand Down Expand Up @@ -539,11 +536,8 @@ impl Contour {
}

/// Replaces the actual lib by the lib given in parameter, returning the old
/// lib if present. Sets a new UUID v4 identifier if none is set already.
/// lib if present.
pub fn replace_lib(&mut self, lib: Plist) -> Option<Plist> {
if self.identifier.is_none() {
self.identifier.replace(Identifier::from_uuidv4());
}
self.lib.replace(lib)
}

Expand Down Expand Up @@ -597,11 +591,8 @@ impl ContourPoint {
}

/// Replaces the actual lib by the lib given in parameter, returning the old
/// lib if present. Sets a new UUID v4 identifier if none is set already.
/// lib if present.
pub fn replace_lib(&mut self, lib: Plist) -> Option<Plist> {
if self.identifier.is_none() {
self.identifier.replace(Identifier::from_uuidv4());
}
self.lib.replace(lib)
}

Expand Down Expand Up @@ -667,11 +658,8 @@ impl Component {
}

/// Replaces the actual lib by the lib given in parameter, returning the old
/// lib if present. Sets a new UUID v4 identifier if none is set already.
/// lib if present.
pub fn replace_lib(&mut self, lib: Plist) -> Option<Plist> {
if self.identifier.is_none() {
self.identifier.replace(Identifier::from_uuidv4());
}
self.lib.replace(lib)
}

Expand Down
5 changes: 1 addition & 4 deletions src/guideline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,8 @@ impl Guideline {
}

/// Replaces the actual lib by the lib given in parameter, returning the old
/// lib if present. Sets a new UUID v4 identifier if none is set already.
/// lib if present.
pub fn replace_lib(&mut self, lib: Plist) -> Option<Plist> {
if self.identifier.is_none() {
self.identifier.replace(Identifier::from_uuidv4());
}
self.lib.replace(lib)
}

Expand Down
5 changes: 0 additions & 5 deletions src/identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ impl Identifier {
Self(string.into())
}

/// Create a new [`Identifier`] from a UUID v4 identifier.
pub fn from_uuidv4() -> Self {
Self::new(uuid::Uuid::new_v4().to_string().as_ref()).unwrap()
}

/// Return the raw identifier, as a `&str`.
pub fn as_str(&self) -> &str {
self.as_ref()
Expand Down
5 changes: 4 additions & 1 deletion src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ pub(crate) fn write_xml_to_file(
}

/// Write XML declarations with custom quote formatting options.
fn write_quote_style(file: &File, options: &WriteOptions) -> Result<(), std::io::Error> {
fn write_quote_style(
#[allow(unused)] file: &File,
options: &WriteOptions,
) -> Result<(), std::io::Error> {
// Optionally modify the XML declaration quote style
match options.quote_style {
QuoteChar::Single => {
Expand Down