diff --git a/frameworks/Rust/axum-xitca/Makefile b/frameworks/Rust/axum-xitca/Makefile index fc6ba34..68207a5 100644 --- a/frameworks/Rust/axum-xitca/Makefile +++ b/frameworks/Rust/axum-xitca/Makefile @@ -1,4 +1,6 @@ -CARGO = cargo +RUSTFLAGS := "-Zthreads=8" + +CARGO = RUSTFLAGS=$(RUSTFLAGS) cargo RUSTC = rustc CROSS = cross @@ -7,7 +9,7 @@ all: build build: $(CARGO) build -release: clean +release: $(CARGO) build --release dev: @@ -53,10 +55,4 @@ freebsd: clean-release loongarch: clean-release $(CROSS) build --release --target loongarch64-unknown-linux-gnu -deps: - python -m venv venus \ - && source venus/bin/activate \ - && pip install -r scripts/requirements.txt \ - && python scripts/download-core.py - .PHONY: all diff --git a/frameworks/Rust/axum/.cargo/config.toml b/frameworks/Rust/axum/.cargo/config.toml index c32d7b2..ee0584d 100644 --- a/frameworks/Rust/axum/.cargo/config.toml +++ b/frameworks/Rust/axum/.cargo/config.toml @@ -1,2 +1,2 @@ [target.x86_64-unknown-linux-gnu] -rustflags = ["-C", "target-cpu=native", "-Z", "threads=8"] +rustflags = ["-C", "target-cpu=native"] diff --git a/frameworks/Rust/axum/src/routes/json.rs b/frameworks/Rust/axum/src/routes/json.rs index 3455484..24795c0 100644 --- a/frameworks/Rust/axum/src/routes/json.rs +++ b/frameworks/Rust/axum/src/routes/json.rs @@ -3,11 +3,9 @@ use std::borrow::Cow; use axum::Json; use serde::{Deserialize, Serialize}; -use crate::error::ErrorCode; - use super::{RouteResponse, RouteResult}; -#[derive(Debug, Deserialize, Serialize)] +#[derive(Serialize, Deserialize, Default)] pub struct JsonData { pub name: Cow<'static, str>, } @@ -15,10 +13,8 @@ pub struct JsonData { pub async fn json() -> RouteResult { let data = JsonData { name: "xfy".into() }; let res = RouteResponse { - code: ErrorCode::Normal, - message: None, data, + ..Default::default() }; - Ok(Json(res)) } diff --git a/frameworks/Rust/axum/src/routes/mod.rs b/frameworks/Rust/axum/src/routes/mod.rs index 17c15ab..be6fd4d 100644 --- a/frameworks/Rust/axum/src/routes/mod.rs +++ b/frameworks/Rust/axum/src/routes/mod.rs @@ -31,6 +31,18 @@ where message: Option>, data: T, } +impl Default for RouteResponse +where + T: Serialize + Default, +{ + fn default() -> Self { + Self { + code: ErrorCode::Normal, + message: None, + data: T::default(), + } + } +} pub type RouteResult = AppResult>>; pub fn routes() -> Router { diff --git a/ui/Makefile b/ui/Makefile index 27b1afa..30dfa01 100644 --- a/ui/Makefile +++ b/ui/Makefile @@ -1,4 +1,6 @@ -CARGO = cargo +RUSTFLAGS := "-Zthreads=8" + +CARGO = RUSTFLAGS=$(RUSTFLAGS) cargo RUSTC = rustc CROSS = cross