Skip to content

Commit

Permalink
chore: bump versions and remove old wasm allocator
Browse files Browse the repository at this point in the history
  • Loading branch information
Vexcited committed Dec 31, 2024
1 parent 6de586f commit 5a04803
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 51 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion fetcher-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fetcher-macros"
version = "0.0.0"
version = "0.1.0"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion fetcher/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fetcher"
version = "0.0.0"
version = "0.1.0"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wasm"
version = "0.0.0"
version = "0.1.0"
edition = "2021"

[dependencies]
Expand Down
33 changes: 0 additions & 33 deletions wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,4 @@
wasm = { git = "https://github.com/LiterateInk/Utilities" }
wasm-bindgen = "0.2" # required for the `wasm_bindgen::prelude::wasm_bindgen` macro
js-sys = "0.3" # required for the `js_sys::Function` type
wee_alloc = "0.4" # required when using `setup_allocator!()`
```

## Usage

### `setup_allocator`

```rust
#[cfg(target_arch = "wasm32")]
wasm::setup_allocator!();
```

Will use the `wee_alloc` crate to set up a global allocator for the `wasm32` target.

### `api_method`

A `fetcher` parameter is automatically added to the function signature.
See the [`fetcher` module](../fetcher) for more information.

```rust
// the method will be called `fetchGitHub` in the generated bindings
#[cfg_attr(target_arch = "wasm32", wasm::api_method(fetchGitHub))]
pub async fn fetch_github(something: String) -> String {
// a `fetcher` variable is available
// if the target architecture is `wasm32`
}

// the method will stille be called `update` in the generated bindings
#[cfg_attr(target_arch = "wasm32", wasm::api_method)]
pub async fn update(something: String) -> String {
// a `fetcher` variable is available
// if the target architecture is `wasm32`
}
```
12 changes: 0 additions & 12 deletions wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,6 @@ pub fn append_fetcher(_args: TokenStream, input: TokenStream) -> TokenStream {
TokenStream::from(output)
}

#[proc_macro]
pub fn setup_allocator(_input: TokenStream) -> TokenStream {
let expanded = quote! {
extern crate wee_alloc;

#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
};

TokenStream::from(expanded)
}

#[proc_macro_derive(Error)]
pub fn derive_wasm_error(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput);
Expand Down

0 comments on commit 5a04803

Please sign in to comment.