mirror of
https://github.com/DefectingCat/phthonus
synced 2025-07-15 16:41:32 +00:00
chore(axum-xitca): add rust flags for makefile
This commit is contained in:
@ -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
|
||||
|
@ -1,2 +1,2 @@
|
||||
[target.x86_64-unknown-linux-gnu]
|
||||
rustflags = ["-C", "target-cpu=native", "-Z", "threads=8"]
|
||||
rustflags = ["-C", "target-cpu=native"]
|
||||
|
@ -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<JsonData> {
|
||||
let data = JsonData { name: "xfy".into() };
|
||||
let res = RouteResponse {
|
||||
code: ErrorCode::Normal,
|
||||
message: None,
|
||||
data,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
Ok(Json(res))
|
||||
}
|
||||
|
@ -31,6 +31,18 @@ where
|
||||
message: Option<Cow<'static, str>>,
|
||||
data: T,
|
||||
}
|
||||
impl<T> Default for RouteResponse<T>
|
||||
where
|
||||
T: Serialize + Default,
|
||||
{
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
code: ErrorCode::Normal,
|
||||
message: None,
|
||||
data: T::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
pub type RouteResult<T> = AppResult<Json<RouteResponse<T>>>;
|
||||
|
||||
pub fn routes() -> Router {
|
||||
|
@ -1,4 +1,6 @@
|
||||
CARGO = cargo
|
||||
RUSTFLAGS := "-Zthreads=8"
|
||||
|
||||
CARGO = RUSTFLAGS=$(RUSTFLAGS) cargo
|
||||
RUSTC = rustc
|
||||
CROSS = cross
|
||||
|
||||
|
Reference in New Issue
Block a user