-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically serialize uuids (#160)
Behind an optional feature flag. Curiously enough it looks like I've found a cargo bug where having a feature named exactly the same as an optional crate, fails to pull in the optional crate. Fixed through a roundabout feature name on core. Co-authored-by: Michał Kawalec <ext.mkawalec@riotgames.com> Co-authored-by: Nick Mosher <nicholastmosher@gmail.com> Co-authored-by: Michal Kawalec <ext.mkawalec@riotgames.com>
- Loading branch information
1 parent
572d56a
commit d9c9f63
Showing
16 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,5 @@ members = [ | |
"cleanup", | ||
"bigint", | ||
"tuples", | ||
"uuid", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "nj-example-uuid" | ||
version = "0.1.0" | ||
authors = ["fluvio.io"] | ||
edition = "2018" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
node-bindgen = { path = "../..", features = ["uuid"] } | ||
uuid = "0.8.2" | ||
|
||
[build-dependencies] | ||
node-bindgen = { path = "../../", features = ["build"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
all: build | ||
|
||
build: | ||
nj-cli build | ||
|
||
test: build | ||
npx -y ts-node test.ts | ||
|
||
clean: | ||
rm -rf dist | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Pass `uuid::Uuid` objects to and from Node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
node_bindgen::build::configure(); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"devDependencies": { | ||
"@types/node": "^15.12.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use node_bindgen::derive::node_bindgen; | ||
|
||
/// Create a new random Uuid to return | ||
#[node_bindgen] | ||
fn make_uuid() -> uuid::Uuid { | ||
uuid::Uuid::parse_str("f7509856-9ae5-4c07-976d-a5b3f983e4af").unwrap() | ||
} | ||
|
||
#[node_bindgen] | ||
fn take_uuid(uuid: uuid::Uuid) { | ||
let string = uuid.to_string(); | ||
assert_eq!(string, "f7509856-9ae5-4c07-976d-a5b3f983e4af"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const assert = require('assert'); | ||
|
||
interface UuidExample { | ||
makeUuid(): string; | ||
takeUuid(uuid: string); | ||
} | ||
let addon: UuidExample = require('./dist'); | ||
|
||
const new_uuid: string = addon.makeUuid(); | ||
assert.equal(new_uuid, "f7509856-9ae5-4c07-976d-a5b3f983e4af"); | ||
|
||
addon.takeUuid(new_uuid); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters