diff --git a/examples/01-app-demos/ecommerce-site/src/api.rs b/examples/01-app-demos/ecommerce-site/src/api.rs index 22b8201f5d..0c236694d5 100644 --- a/examples/01-app-demos/ecommerce-site/src/api.rs +++ b/examples/01-app-demos/ecommerce-site/src/api.rs @@ -1,4 +1,3 @@ -use chrono::{DateTime, Utc}; use dioxus::prelude::Result; use serde::{Deserialize, Serialize}; use std::fmt::Display; @@ -71,36 +70,3 @@ impl Display for Sort { } } } - -#[derive(Serialize, Deserialize)] -struct User { - id: usize, - email: String, - username: String, - password: String, - name: FullName, - phone: String, -} - -#[derive(Serialize, Deserialize)] -struct FullName { - firstname: String, - lastname: String, -} - -#[derive(Serialize, Deserialize, Clone)] -struct Cart { - id: usize, - #[serde(rename = "userId")] - user_id: usize, - data: String, - products: Vec, - date: DateTime, -} - -#[derive(Serialize, Deserialize, Clone)] -struct ProductInCart { - #[serde(rename = "productId")] - product_id: usize, - quantity: usize, -} diff --git a/packages/const-serialize/Cargo.toml b/packages/const-serialize/Cargo.toml index d9d5cf1010..9d4b4e2647 100644 --- a/packages/const-serialize/Cargo.toml +++ b/packages/const-serialize/Cargo.toml @@ -8,6 +8,7 @@ license = "MIT OR Apache-2.0" repository = "https://github.com/dioxuslabs/dioxus" homepage = "https://dioxuslabs.com/learn/0.5/getting_started" keywords = ["const", "serialize"] +rust-version = "1.80.0" [dependencies] const-serialize-macro = { workspace = true } diff --git a/packages/core-types/src/attributes.rs b/packages/core-types/src/attributes.rs index e69de29bb2..8b13789179 100644 --- a/packages/core-types/src/attributes.rs +++ b/packages/core-types/src/attributes.rs @@ -0,0 +1 @@ + diff --git a/packages/generational-box/Cargo.toml b/packages/generational-box/Cargo.toml index f8e8f767b5..686c8c7c6c 100644 --- a/packages/generational-box/Cargo.toml +++ b/packages/generational-box/Cargo.toml @@ -7,7 +7,7 @@ description = "A box backed by a generational runtime" license = "MIT OR Apache-2.0" repository = "https://github.com/DioxusLabs/dioxus/" keywords = ["generational", "box", "memory", "allocator"] -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +rust-version = "1.80.0" [dependencies] parking_lot = { workspace = true } diff --git a/packages/generational-box/src/sync.rs b/packages/generational-box/src/sync.rs index 58a627ab49..c106525848 100644 --- a/packages/generational-box/src/sync.rs +++ b/packages/generational-box/src/sync.rs @@ -22,19 +22,15 @@ type RwLockStorageEntryMut = RwLockWriteGuard<'static, StorageEntry>; type AnyRefMut = MappedRwLockWriteGuard<'static, Box>; +#[derive(Default)] pub(crate) enum RwLockStorageEntryData { Reference(GenerationalPointer), Rc(RcStorageEntry>), Data(Box), + #[default] Empty, } -impl Default for RwLockStorageEntryData { - fn default() -> Self { - Self::Empty - } -} - impl Debug for RwLockStorageEntryData { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { diff --git a/packages/generational-box/src/unsync.rs b/packages/generational-box/src/unsync.rs index 2202cafd2b..0a52f6ff3c 100644 --- a/packages/generational-box/src/unsync.rs +++ b/packages/generational-box/src/unsync.rs @@ -21,10 +21,12 @@ thread_local! { static UNSYNC_RUNTIME: RefCell> = const { RefCell::new(Vec::new()) }; } +#[derive(Default)] pub(crate) enum RefCellStorageEntryData { Reference(GenerationalPointer), Rc(RcStorageEntry>), Data(Box), + #[default] Empty, } @@ -39,12 +41,6 @@ impl Debug for RefCellStorageEntryData { } } -impl Default for RefCellStorageEntryData { - fn default() -> Self { - Self::Empty - } -} - /// A unsync storage. This is the default storage type. #[derive(Default)] pub struct UnsyncStorage { diff --git a/packages/html/src/events/pointer.rs b/packages/html/src/events/pointer.rs index d6ce3602a4..d105f5ffb8 100644 --- a/packages/html/src/events/pointer.rs +++ b/packages/html/src/events/pointer.rs @@ -75,10 +75,10 @@ pub trait HasPointerData: PointerInteraction { fn pointer_id(&self) -> i32; /// Gets the width (magnitude on the X axis), in CSS pixels, of the contact geometry of the pointer. - fn width(&self) -> i32; + fn width(&self) -> f64; /// Gets the height (magnitude on the Y axis), in CSS pixels, of the contact geometry of the pointer. - fn height(&self) -> i32; + fn height(&self) -> f64; /// Gets the normalized pressure of the pointer input in the range of 0 to 1, fn pressure(&self) -> f32; @@ -145,12 +145,12 @@ impl PointerData { } /// Gets the width (magnitude on the X axis), in CSS pixels, of the contact geometry of the pointer. - pub fn width(&self) -> i32 { + pub fn width(&self) -> f64 { self.inner.width() } /// Gets the height (magnitude on the Y axis), in CSS pixels, of the contact geometry of the pointer. - pub fn height(&self) -> i32 { + pub fn height(&self) -> f64 { self.inner.height() } @@ -238,10 +238,10 @@ pub struct SerializedPointerData { pointer_id: i32, /// The width (magnitude on the X axis), in CSS pixels, of the contact geometry of the pointer. - width: i32, + width: f64, /// The height (magnitude on the Y axis), in CSS pixels, of the contact geometry of the pointer. - height: i32, + height: f64, /// The normalized pressure of the pointer input in the range of 0 to 1, pressure: f32, @@ -271,11 +271,11 @@ impl HasPointerData for SerializedPointerData { self.pointer_id } - fn width(&self) -> i32 { + fn width(&self) -> f64 { self.width } - fn height(&self) -> i32 { + fn height(&self) -> f64 { self.height } diff --git a/packages/html/src/events/scroll.rs b/packages/html/src/events/scroll.rs index eac483ea6d..0b77f01767 100644 --- a/packages/html/src/events/scroll.rs +++ b/packages/html/src/events/scroll.rs @@ -26,11 +26,11 @@ impl ScrollData { self.inner.as_any().downcast_ref::() } - pub fn scroll_top(&self) -> i32 { + pub fn scroll_top(&self) -> f64 { self.inner.scroll_top() } - pub fn scroll_left(&self) -> i32 { + pub fn scroll_left(&self) -> f64 { self.inner.scroll_left() } @@ -79,8 +79,8 @@ impl PartialEq for ScrollData { /// A serialized version of ScrollData #[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, Clone)] pub struct SerializedScrollData { - pub scroll_top: i32, - pub scroll_left: i32, + pub scroll_top: f64, + pub scroll_left: f64, pub scroll_width: i32, pub scroll_height: i32, pub client_width: i32, @@ -107,11 +107,11 @@ impl HasScrollData for SerializedScrollData { self } - fn scroll_top(&self) -> i32 { + fn scroll_top(&self) -> f64 { self.scroll_top } - fn scroll_left(&self) -> i32 { + fn scroll_left(&self) -> f64 { self.scroll_left } @@ -154,10 +154,10 @@ pub trait HasScrollData: std::any::Any { fn as_any(&self) -> &dyn std::any::Any; /// Get the vertical scroll position - fn scroll_top(&self) -> i32; + fn scroll_top(&self) -> f64; /// Get the horizontal scroll position - fn scroll_left(&self) -> i32; + fn scroll_left(&self) -> f64; /// Get the total scrollable width fn scroll_width(&self) -> i32; diff --git a/packages/html/src/point_interaction.rs b/packages/html/src/point_interaction.rs index b0e34f7809..e0d6796be6 100644 --- a/packages/html/src/point_interaction.rs +++ b/packages/html/src/point_interaction.rs @@ -70,12 +70,12 @@ pub struct SerializedPointInteraction { /// The horizontal coordinate within the application's viewport at which the event occurred (as opposed to the coordinate within the page). /// /// For example, clicking on the left edge of the viewport will always result in a mouse event with a clientX value of 0, regardless of whether the page is scrolled horizontally. - pub client_x: i32, + pub client_x: f64, /// The vertical coordinate within the application's viewport at which the event occurred (as opposed to the coordinate within the page). /// /// For example, clicking on the top edge of the viewport will always result in a mouse event with a clientY value of 0, regardless of whether the page is scrolled vertically. - pub client_y: i32, + pub client_y: f64, /// True if the control key was down when the mouse event was fired. pub ctrl_key: bool, @@ -84,26 +84,26 @@ pub struct SerializedPointInteraction { pub meta_key: bool, /// The offset in the X coordinate of the mouse pointer between that event and the padding edge of the target node. - pub offset_x: i32, + pub offset_x: f64, /// The offset in the Y coordinate of the mouse pointer between that event and the padding edge of the target node. - pub offset_y: i32, + pub offset_y: f64, /// The X (horizontal) coordinate (in pixels) of the mouse, relative to the left edge of the entire document. This includes any portion of the document not currently visible. /// /// Being based on the edge of the document as it is, this property takes into account any horizontal scrolling of the page. For example, if the page is scrolled such that 200 pixels of the left side of the document are scrolled out of view, and the mouse is clicked 100 pixels inward from the left edge of the view, the value returned by pageX will be 300. - pub page_x: i32, + pub page_x: f64, /// The Y (vertical) coordinate in pixels of the event relative to the whole document. /// /// See `page_x`. - pub page_y: i32, + pub page_y: f64, /// The X coordinate of the mouse pointer in global (screen) coordinates. - pub screen_x: i32, + pub screen_x: f64, /// The Y coordinate of the mouse pointer in global (screen) coordinates. - pub screen_y: i32, + pub screen_y: f64, /// True if the shift key was down when the mouse event was fired. pub shift_key: bool, @@ -122,10 +122,10 @@ impl SerializedPointInteraction { let meta_key = modifiers.contains(Modifiers::META); let shift_key = modifiers.contains(Modifiers::SHIFT); - let [client_x, client_y]: [i32; 2] = coordinates.client().cast().into(); - let [offset_x, offset_y]: [i32; 2] = coordinates.element().cast().into(); - let [page_x, page_y]: [i32; 2] = coordinates.page().cast().into(); - let [screen_x, screen_y]: [i32; 2] = coordinates.screen().cast().into(); + let [client_x, client_y]: [f64; 2] = coordinates.client().cast().into(); + let [offset_x, offset_y]: [f64; 2] = coordinates.element().cast().into(); + let [page_x, page_y]: [f64; 2] = coordinates.page().cast().into(); + let [screen_x, screen_y]: [f64; 2] = coordinates.screen().cast().into(); Self { button: trigger_button .map_or(MouseButton::default(), |b| b) @@ -194,21 +194,21 @@ impl ModifiersInteraction for SerializedPointInteraction { #[cfg(feature = "serialize")] impl InteractionLocation for SerializedPointInteraction { fn client_coordinates(&self) -> ClientPoint { - ClientPoint::new(self.client_x.into(), self.client_y.into()) + ClientPoint::new(self.client_x, self.client_y) } fn screen_coordinates(&self) -> ScreenPoint { - ScreenPoint::new(self.screen_x.into(), self.screen_y.into()) + ScreenPoint::new(self.screen_x, self.screen_y) } fn page_coordinates(&self) -> PagePoint { - PagePoint::new(self.page_x.into(), self.page_y.into()) + PagePoint::new(self.page_x, self.page_y) } } #[cfg(feature = "serialize")] impl InteractionElementOffset for SerializedPointInteraction { fn element_coordinates(&self) -> ElementPoint { - ElementPoint::new(self.offset_x.into(), self.offset_y.into()) + ElementPoint::new(self.offset_x, self.offset_y) } } diff --git a/packages/web/src/events/pointer.rs b/packages/web/src/events/pointer.rs index 2764122eb3..b99a388a7e 100644 --- a/packages/web/src/events/pointer.rs +++ b/packages/web/src/events/pointer.rs @@ -13,12 +13,12 @@ impl HasPointerData for Synthetic { self.event.pointer_id() } - fn width(&self) -> i32 { - self.event.width() + fn width(&self) -> f64 { + self.event.width() as _ } - fn height(&self) -> i32 { - self.event.height() + fn height(&self) -> f64 { + self.event.height() as _ } fn pressure(&self) -> f32 { diff --git a/packages/web/src/events/scroll.rs b/packages/web/src/events/scroll.rs index 94d164ddd6..268bf01cc3 100644 --- a/packages/web/src/events/scroll.rs +++ b/packages/web/src/events/scroll.rs @@ -9,32 +9,32 @@ impl HasScrollData for Synthetic { &self.event } - fn scroll_top(&self) -> i32 { + fn scroll_top(&self) -> f64 { if let Some(target) = self.event.target().as_ref() { if let Some(element) = target.dyn_ref::() { - return element.scroll_top(); + return element.scroll_top() as f64; } else if let Some(element) = target .dyn_ref::() .and_then(|document| document.document_element()) { - return element.scroll_top(); + return element.scroll_top() as f64; } } - 0 + 0f64 } - fn scroll_left(&self) -> i32 { + fn scroll_left(&self) -> f64 { if let Some(target) = self.event.target().as_ref() { if let Some(element) = target.dyn_ref::() { - return element.scroll_left(); + return element.scroll_left() as f64; } else if let Some(element) = target .dyn_ref::() .and_then(|document| document.document_element()) { - return element.scroll_left(); + return element.scroll_left() as f64; } } - 0 + 0f64 } fn scroll_width(&self) -> i32 {