From 2b05abea03cdaca42b0ab69852799ee1542b467f Mon Sep 17 00:00:00 2001 From: u <@> Date: Wed, 11 Mar 2026 10:07:13 -0700 Subject: 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 --- .cargo/config.toml | 6 +++++- Cargo.toml | 6 +++--- rust-toolchain.toml | 5 +++++ src/lib.rs | 17 +---------------- wrangler.toml | 2 +- 5 files changed, 15 insertions(+), 21 deletions(-) create mode 100644 rust-toolchain.toml 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"] diff --git a/Cargo.toml b/Cargo.toml index 057f95c..5899aa5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" ] diff --git a/src/lib.rs b/src/lib.rs index 52169b4..6322e6d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 { - match r.body() { - ResponseBody::Body(bytes) => unsafe { - let bytes: &mut Vec = 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 { Router::new() @@ -36,7 +21,7 @@ async fn fetch(req: Request, env: Env, _ctx: Context) -> Result { 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" -- cgit v1.2.3