Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
wasmify-sophia : Add exported methods

https://github.com/BruJu/wasmify-sophia

wasm_bindgen_dataset!(TreedDataset, "TreedDataset", SophiaExportDataset);

+use crate::wrapping::*;
+
+#[wasm_bindgen(js_class="TreedDataset")]
+impl SophiaExportDataset {
+    pub fn get_nb_underlying(&self) -> usize {
+        self.base.dataset().get_number_of_underlying_trees()
+    }
+}

And that's it.

Explanation

  • The third argument is the name of the class that will be exported
  • Rust enables you to define multiple impl block
  • base is the adapter, base.dataset() is the Sophia compliant dataset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment