From ca4d4ae8e1f99f81d27f4ebaecb68540b28d0040 Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Mon, 19 Dec 2022 15:10:50 -0800 Subject: [PATCH] chore: dont get rid of form data --- packages/html/src/events/form.rs | 33 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/packages/html/src/events/form.rs b/packages/html/src/events/form.rs index 9f2740874..3e4e00e0e 100644 --- a/packages/html/src/events/form.rs +++ b/packages/html/src/events/form.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, fmt::Debug}; +use std::{collections::HashMap, fmt::Debug, sync::Arc}; use dioxus_core::Event; @@ -6,13 +6,20 @@ pub type FormEvent = Event; /* DOMEvent: Send + SyncTarget relatedTarget */ #[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))] -#[derive(Clone, PartialEq, Default)] +#[derive(Clone)] pub struct FormData { pub value: String, pub values: HashMap, - // #[cfg_attr(feature = "serialize", serde(skip))] - // pub files: Option>, + + #[cfg_attr(feature = "serialize", serde(skip))] + pub files: Option>, +} + +impl PartialEq for FormData { + fn eq(&self, other: &Self) -> bool { + self.value == other.value && self.values == other.values + } } impl Debug for FormData { @@ -24,17 +31,17 @@ impl Debug for FormData { } } -// #[async_trait::async_trait(?Send)] -// pub trait FileEngine { -// // get a list of file names -// fn files(&self) -> Vec; +#[async_trait::async_trait(?Send)] +pub trait FileEngine { + // get a list of file names + fn files(&self) -> Vec; -// // read a file to bytes -// async fn read_file(&self, file: &str) -> Option>; + // read a file to bytes + async fn read_file(&self, file: &str) -> Option>; -// // read a file to string -// async fn read_file_to_string(&self, file: &str) -> Option; -// } + // read a file to string + async fn read_file_to_string(&self, file: &str) -> Option; +} impl_event! { FormData;