diff options
author | natrixaeria <janng@gmx.de> | 2019-05-26 16:09:03 +0200 |
---|---|---|
committer | natrixaeria <janng@gmx.de> | 2019-05-26 16:09:03 +0200 |
commit | fb31751fab32c8b67affd75603084e4f143bc758 (patch) | |
tree | 1f4ba292480c00e8935748a59b1c067c0c5126f1 | |
parent | e2e4f0f698b95ca979e78ac12fa2395635321dd3 (diff) |
Add basic project structure
-rw-r--r-- | WebInterface/wasm/asm-paint/Cargo.toml | 2 | ||||
-rwxr-xr-x | WebInterface/wasm/asm-paint/run | 2 | ||||
-rw-r--r-- | WebInterface/wasm/asm-paint/src/app.rs | 16 | ||||
-rw-r--r-- | WebInterface/wasm/asm-paint/src/lib.rs | 7 | ||||
-rw-r--r-- | WebInterface/wasm/asm-paint/src/site.rs | 18 |
5 files changed, 42 insertions, 3 deletions
diff --git a/WebInterface/wasm/asm-paint/Cargo.toml b/WebInterface/wasm/asm-paint/Cargo.toml index e8f5acb..e2b1e17 100644 --- a/WebInterface/wasm/asm-paint/Cargo.toml +++ b/WebInterface/wasm/asm-paint/Cargo.toml @@ -3,7 +3,7 @@ name = "asm-paint-rs" version = "0.1.0" authors = [ "natrixaeria", - "Dennis Kobert <d-kobert@web.de>" + "TrueDoctor" ] edition = "2018" diff --git a/WebInterface/wasm/asm-paint/run b/WebInterface/wasm/asm-paint/run index 61c1997..1da1e35 100755 --- a/WebInterface/wasm/asm-paint/run +++ b/WebInterface/wasm/asm-paint/run @@ -1,3 +1,3 @@ #!/bin/sh -wasm-pack build --target web +wasm-pack build --release --target web diff --git a/WebInterface/wasm/asm-paint/src/app.rs b/WebInterface/wasm/asm-paint/src/app.rs new file mode 100644 index 0000000..d5d0e45 --- /dev/null +++ b/WebInterface/wasm/asm-paint/src/app.rs @@ -0,0 +1,16 @@ +use crate::site::Site; + +pub struct App { + site: Site, +} + +impl App { + pub fn new() -> Option<Self> { + Some(Self { + site: Site::from_current()?, + }) + } + + pub fn run(&self) { + } +} diff --git a/WebInterface/wasm/asm-paint/src/lib.rs b/WebInterface/wasm/asm-paint/src/lib.rs index fea9d0f..037e8e9 100644 --- a/WebInterface/wasm/asm-paint/src/lib.rs +++ b/WebInterface/wasm/asm-paint/src/lib.rs @@ -1,4 +1,6 @@ mod client_logger; +mod site; +mod app; use wasm_bindgen::prelude::*; @@ -9,5 +11,8 @@ extern crate log; pub fn entry() { client_logger::init_logger(); - info!("{}", 42); + info!("begin running wasm application"); + + let app = app::App::new().unwrap(); + app.run(); } diff --git a/WebInterface/wasm/asm-paint/src/site.rs b/WebInterface/wasm/asm-paint/src/site.rs new file mode 100644 index 0000000..740cb90 --- /dev/null +++ b/WebInterface/wasm/asm-paint/src/site.rs @@ -0,0 +1,18 @@ +use web_sys; + +pub struct Site { + window: web_sys::Window, + document: web_sys::Document, +} + +impl Site { + pub fn from_current() -> Option<Self> { + let window = web_sys::window() + .or_else(|| {error!("unable to query window"); None})?; + let document = window.document() + .or_else(|| {error!("unable to query document"); None})?; + Some(Self { + window, document + }) + } +} |