From 4ef86040ddc4f5f63465776f1dc984163a449bbe Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sat, 2 Sep 2023 13:02:10 +0300 Subject: feat(tazjin/presentations): add (intentionally) broken WASM demo This demonstrates a Rust stdlib call that just causes runtime panics on WASM, for explaining the problems with porting Tvixbolt. Change-Id: Ief974f1bba509fdac4b9bc9f862ee8f4dfc5158e Reviewed-on: https://cl.tvl.fyi/c/depot/+/9206 Tested-by: BuildkiteCI Reviewed-by: Mark Shevchenko Autosubmit: tazjin --- .../tvix-eval-2023/wasm-fs-demo/src/main.rs | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 users/tazjin/presentations/tvix-eval-2023/wasm-fs-demo/src/main.rs (limited to 'users/tazjin/presentations/tvix-eval-2023/wasm-fs-demo/src/main.rs') diff --git a/users/tazjin/presentations/tvix-eval-2023/wasm-fs-demo/src/main.rs b/users/tazjin/presentations/tvix-eval-2023/wasm-fs-demo/src/main.rs new file mode 100644 index 000000000000..4ad177ad7a94 --- /dev/null +++ b/users/tazjin/presentations/tvix-eval-2023/wasm-fs-demo/src/main.rs @@ -0,0 +1,41 @@ +use std::time::{SystemTime, UNIX_EPOCH}; +use yew::prelude::*; + +fn time_example() -> Html { + let epoch = match SystemTime::now().duration_since(UNIX_EPOCH) { + Ok(duration) => duration.as_secs(), + Err(err) => { + return html! { + format!("failed to calculate duration: {}", err) + } + } + }; + + html! { +

+ {"Seconds since epoch: "}{epoch} +

+ } +} + +struct App; +impl Component for App { + type Message = (); + type Properties = (); + + fn create(_: &Context) -> Self { + Self + } + + fn update(&mut self, _: &Context, _: Self::Message) -> bool { + false + } + + fn view(&self, _: &Context) -> Html { + time_example() + } +} + +fn main() { + yew::Renderer::::new().render(); +} -- cgit 1.4.1