diff options
| author | u <@> | 2026-03-11 10:07:13 -0700 |
|---|---|---|
| committer | u <@> | 2026-03-11 10:09:14 -0700 |
| commit | 2b05abea03cdaca42b0ab69852799ee1542b467f (patch) | |
| tree | d2fb7786eccb60afec15f95ab44ffb6b761dedd2 | |
| parent | 9bdd9eb5442bbdeefa08ea60fd966c8f9a83c543 (diff) | |
build-std, give up on transmute dance
the file is streamed anyway.
build-std was failing with workers 0.7 but they fixed it? maybe rustup
update fixed it and my stuff was mismatched. idk. its annoying
| -rw-r--r-- | .cargo/config.toml | 6 | ||||
| -rw-r--r-- | Cargo.toml | 6 | ||||
| -rw-r--r-- | rust-toolchain.toml | 5 | ||||
| -rw-r--r-- | src/lib.rs | 17 | ||||
| -rw-r--r-- | wrangler.toml | 2 |
5 files changed, 15 insertions, 21 deletions
diff --git a/.cargo/config.toml b/.cargo/config.toml index 0a977cc..ba74195 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,2 +1,6 @@ [target.'cfg(target_family="wasm")'] -rustflags = ["-C", "llvm-args=--mattr=+bulk-memory-opt,+simd128,+relaxed-simd,+tail-call,+extended-const", "-C", "target-feature=+simd128,+relaxed-simd,+tail-call,+extended-const"] +rustflags = ["-C", "llvm-args=--mattr=+bulk-memory-opt,+simd128,+relaxed-simd,+tail-call,+extended-const", + "-C", "target-feature=+simd128,+relaxed-simd,+tail-call,+extended-const"] + +[unstable] +build-std = ["compiler_builtins", "std", "core", "alloc", "panic_abort"] @@ -1,15 +1,15 @@ [package] name = "ataxia-rs" version = "0.1.0" -edition = "2021" +edition = "2024" authors = ["user"] [lib] crate-type = ["cdylib"] [dependencies] -worker = { version = "0.7", default-features = false } -# worker-macros = { version = "0.7" } +worker = { version = "0.7.5", default-features = false } +# worker-macros = { version = "0.7.5" } maud = { version = "0.27.0" } num = { version = "0.4.3", default-features = false } diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..eacff52 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,5 @@ +[toolchain] +channel = "nightly-2026-03-11" +profile = "default" +components = ["rust-src"] +targets = [ "wasm32-unknown-unknown" ] @@ -5,7 +5,6 @@ #![allow(internal_features)] #![allow(mutable_transmutes)] use maud::{html, Markup, PreEscaped, DOCTYPE}; -use std::mem::{take, transmute}; use worker::*; pub mod dateparse; @@ -15,20 +14,6 @@ use crate::{ solar::{dow, solar}, }; -async fn text(r: &mut Response) -> Result<String> { - match r.body() { - ResponseBody::Body(bytes) => unsafe { - let bytes: &mut Vec<u8> = transmute(bytes); - Ok(String::from_utf8_unchecked(take(bytes))) - }, - ResponseBody::Empty => Ok(String::new()), - ResponseBody::Stream(_) => unsafe { - let bytes = r.bytes().await?; - Ok(String::from_utf8_unchecked(bytes)) - }, - } -} - #[event(fetch)] async fn fetch(req: Request, env: Env, _ctx: Context) -> Result<Response> { Router::new() @@ -36,7 +21,7 @@ async fn fetch(req: Request, env: Env, _ctx: Context) -> Result<Response> { let u = req.url()?; let a = ctx.env.assets("ASSETS")?; let mut a = a.fetch(u.join("_/diary")?, None).await?; - let a = text(&mut a).await?; + let a = unsafe { String::from_utf8_unchecked(a.bytes().await?) }; bone("shitpit", "look in the sky! it's a bird! it's a plane! no it's superego!", html! { p { "The numbering system for people (#1, #2, ...) is arbitrary and " diff --git a/wrangler.toml b/wrangler.toml index 3e66e78..e5b265e 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -3,7 +3,7 @@ main = "build/index.js" compatibility_date = "2026-03-01" [build] -command = "cargo install -q \"worker-build@^0.7\" && worker-build --release" +command = "cargo install -q \"worker-build@^0.7.5\" && worker-build --release" [assets] directory = "./assets" |
