Library for Derive Macros and impl IntoResponse trait

This commit is contained in:
Martin Berg Alstad
2024-06-17 00:47:07 +02:00
parent 6b6f4b4779
commit 9226060397
10 changed files with 104 additions and 25 deletions

View File

@ -1,6 +1,7 @@
use axum::Json;
use axum::response::{IntoResponse, Response};
use serde::Serialize;
use derive::IntoResponse;
use crate::expressions::expression::Expression;
use crate::expressions::simplify::Law;
@ -45,7 +46,7 @@ impl Operation {
}
}
#[derive(Serialize)]
#[derive(Serialize, IntoResponse)]
#[serde(rename_all = "camelCase")]
pub struct SimplifyResponse {
pub before: String,
@ -56,33 +57,14 @@ pub struct SimplifyResponse {
pub truth_table: Option<TruthTable>,
}
// TODO derive macro
impl IntoResponse for SimplifyResponse {
fn into_response(self) -> Response {
BaseResponse::create(self)
}
}
#[derive(Serialize)]
#[derive(Serialize, IntoResponse)]
#[serde(rename_all = "camelCase")]
pub struct IsLegalResponse {
pub is_legal: bool,
}
impl IntoResponse for IsLegalResponse {
fn into_response(self) -> Response {
BaseResponse::create(self)
}
}
#[derive(Serialize)]
#[derive(Serialize, IntoResponse)]
#[serde(rename_all = "camelCase")]
pub struct TruthTableResponse {
pub truth_table: TruthTable,
}
impl IntoResponse for TruthTableResponse {
fn into_response(self) -> Response {
BaseResponse::create(self)
}
}