This commit is contained in:
2023-05-10 00:48:25 +02:00
parent bbcdad7809
commit 9dad419dd2
5 changed files with 29 additions and 25 deletions

View File

@@ -21,8 +21,8 @@ impl Home {
} }
} }
impl Into<Markup> for Home { impl From<Home> for Markup {
fn into(self) -> Markup { fn from(val: Home) -> Self {
self.doc val.doc
} }
} }

View File

@@ -32,9 +32,9 @@ impl Inventory {
} }
} }
impl Into<Markup> for Inventory { impl From<Inventory> for Markup {
fn into(self) -> Markup { fn from(val: Inventory) -> Self {
self.doc val.doc
} }
} }
@@ -144,9 +144,9 @@ impl InventoryCategoryList {
} }
} }
impl Into<Markup> for InventoryCategoryList { impl From<InventoryCategoryList> for Markup {
fn into(self) -> Markup { fn from(val: InventoryCategoryList) -> Self {
self.doc val.doc
} }
} }
@@ -226,9 +226,9 @@ impl InventoryItemList {
} }
} }
impl Into<Markup> for InventoryItemList { impl From<InventoryItemList> for Markup {
fn into(self) -> Markup { fn from(val: InventoryItemList) -> Self {
self.doc val.doc
} }
} }
@@ -339,9 +339,9 @@ impl InventoryNewItemForm {
} }
} }
impl Into<Markup> for InventoryNewItemForm { impl From<InventoryNewItemForm> for Markup {
fn into(self) -> Markup { fn from(val: InventoryNewItemForm) -> Self {
self.doc val.doc
} }
} }
// impl InventoryItemList { // impl InventoryItemList {

View File

@@ -66,7 +66,7 @@ impl Root {
Self { doc } Self { doc }
} }
pub fn to_string(self) -> String { pub fn into_string(self) -> String {
self.doc.into_string() self.doc.into_string()
} }
} }

View File

@@ -31,8 +31,8 @@ impl TripList {
} }
} }
impl Into<Markup> for TripList { impl From<TripList> for Markup {
fn into(self) -> Markup { fn from(val: TripList) -> Self {
self.doc val.doc
} }
} }

View File

@@ -19,8 +19,6 @@ use sqlx::{
use serde::Deserialize; use serde::Deserialize;
use tracing_subscriber;
use futures::TryStreamExt; use futures::TryStreamExt;
use uuid::{uuid, Uuid}; use uuid::{uuid, Uuid};
@@ -51,6 +49,12 @@ impl ClientState {
} }
} }
impl Default for ClientState {
fn default() -> Self {
Self::new()
}
}
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), sqlx::Error> { async fn main() -> Result<(), sqlx::Error> {
tracing_subscriber::fmt() tracing_subscriber::fmt()
@@ -99,7 +103,7 @@ async fn main() -> Result<(), sqlx::Error> {
async fn root() -> (StatusCode, Html<String>) { async fn root() -> (StatusCode, Html<String>) {
( (
StatusCode::OK, StatusCode::OK,
Html::from(Root::build(Home::build().into(), TopLevelPage::None).to_string()), Html::from(Root::build(Home::build().into(), TopLevelPage::None).into_string()),
) )
} }
@@ -164,7 +168,7 @@ async fn inventory(
.into(), .into(),
TopLevelPage::Inventory, TopLevelPage::Inventory,
) )
.to_string(), .into_string(),
), ),
)) ))
} }
@@ -188,7 +192,7 @@ async fn trips(
Ok(( Ok((
StatusCode::OK, StatusCode::OK,
Html::from(Root::build(TripList::build(trips).into(), TopLevelPage::Trips).to_string()), Html::from(Root::build(TripList::build(trips).into(), TopLevelPage::Trips).into_string()),
)) ))
} }
@@ -280,7 +284,7 @@ async fn inventory_item_delete(
.bind(id.to_string()) .bind(id.to_string())
.execute(&state.database_pool) .execute(&state.database_pool)
.await .await
.map_err(|e| ((StatusCode::BAD_REQUEST, e.to_string())))?; .map_err(|e| (StatusCode::BAD_REQUEST, e.to_string()))?;
Ok(Redirect::to( Ok(Redirect::to(
headers headers