Skip to content

Commit

Permalink
"method" attribute only needed for js imported objects.
Browse files Browse the repository at this point in the history
Also changed web demo to use getters/setters.
  • Loading branch information
daidoji committed Dec 13, 2023
1 parent fbf111f commit 5840093
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
18 changes: 9 additions & 9 deletions wasm/demo/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@
let dater = Dater.new_with_dts(dts);
document.write("<p>Date:</p>");
document.write("<code>")
document.write("dts: " + dater.dts() + "<br/>");
document.write("dtsb: " + dater.dtsb() + "<br/>");
document.write("code: " + dater.code() + "<br/>");
document.write("size: " + dater.size() + "<br/>");
document.write("raw: " + dater.raw() + "<br/>");
document.write("qb64: " + dater.qb64() + "<br/>");
document.write("qb64b: " + dater.qb64b() + "<br/>");
document.write("qb2: " + dater.qb2() + "<br/>");
document.write("dts: " + dater.dts + "<br/>");
document.write("dtsb: " + dater.dtsb + "<br/>");
document.write("code: " + dater.code + "<br/>");
document.write("size: " + dater.size + "<br/>");
document.write("raw: " + dater.raw + "<br/>");
document.write("qb64: " + dater.qb64 + "<br/>");
document.write("qb64b: " + dater.qb64b + "<br/>");
document.write("qb2: " + dater.qb2 + "<br/>");
try {
dater = Dater.new_with_dts(dts = "asdf");
document.write("Wrong dater: " + dater.dts() + "<br/>");
document.write("Wrong dater: " + dater.dts + "<br/>");
} catch (error) {
document.write("Error: " + error + "<br/>");
document.write("Error name: " + error.name + "<br/>");
Expand Down
16 changes: 8 additions & 8 deletions wasm/src/primitives/dater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,42 +56,42 @@ impl DaterWrapper {
Ok(DaterWrapper(dater))
}

#[wasm_bindgen(method, getter)]
#[wasm_bindgen(getter)]
pub fn dts(&self) -> Result<String> {
self.0.dts().as_js().map_err(JsValue::from)
}

#[wasm_bindgen(method, getter)]
#[wasm_bindgen(getter)]
pub fn dtsb(&self) -> Result<Vec<u8>> {
self.0.dtsb().as_js().map_err(JsValue::from)
}

#[wasm_bindgen(method, getter)]
#[wasm_bindgen(getter)]
pub fn code(&self) -> String {
self.0.code()
}

#[wasm_bindgen(method, getter)]
#[wasm_bindgen(getter)]
pub fn size(&self) -> u32 {
self.0.size()
}

#[wasm_bindgen(method, getter)]
#[wasm_bindgen(getter)]
pub fn raw(&self) -> Vec<u8> {
self.0.raw()
}

#[wasm_bindgen(method, getter)]
#[wasm_bindgen(getter)]
pub fn qb64(&self) -> Result<String> {
self.0.qb64().as_js().map_err(JsValue::from)
}

#[wasm_bindgen(method, getter)]
#[wasm_bindgen(getter)]
pub fn qb64b(&self) -> Result<Vec<u8>> {
self.0.qb64b().as_js().map_err(JsValue::from)
}

#[wasm_bindgen(method, getter)]
#[wasm_bindgen(getter)]
pub fn qb2(&self) -> Result<Vec<u8>> {
self.0.qb2().as_js().map_err(JsValue::from)
}
Expand Down

0 comments on commit 5840093

Please sign in to comment.