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 {
fn into(self) -> Markup {
self.doc
impl From<Home> for Markup {
fn from(val: Home) -> Self {
val.doc
}
}

View File

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

View File

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

View File

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

View File

@@ -19,8 +19,6 @@ use sqlx::{
use serde::Deserialize;
use tracing_subscriber;
use futures::TryStreamExt;
use uuid::{uuid, Uuid};
@@ -51,6 +49,12 @@ impl ClientState {
}
}
impl Default for ClientState {
fn default() -> Self {
Self::new()
}
}
#[tokio::main]
async fn main() -> Result<(), sqlx::Error> {
tracing_subscriber::fmt()
@@ -99,7 +103,7 @@ async fn main() -> Result<(), sqlx::Error> {
async fn root() -> (StatusCode, Html<String>) {
(
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(),
TopLevelPage::Inventory,
)
.to_string(),
.into_string(),
),
))
}
@@ -188,7 +192,7 @@ async fn trips(
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())
.execute(&state.database_pool)
.await
.map_err(|e| ((StatusCode::BAD_REQUEST, e.to_string())))?;
.map_err(|e| (StatusCode::BAD_REQUEST, e.to_string()))?;
Ok(Redirect::to(
headers