Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make items serde serializable #115

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ documentation = "https://docs.rs/speedy2d"
default = ["windowing", "image-loading"]
windowing = ["glutin", "winit", "glutin-winit", "raw-window-handle"]
image-loading = ["image"]
serde = ["dep:serde"]

[dependencies]
glow = "0.7"
Expand All @@ -33,6 +34,9 @@ smallvec = "1.9.0"
# For image_loading feature
image = { version = "0.23", optional = true }

# For serde feature
serde = { version = "1", features = ["derive"], optional = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
# For windowing feature
glutin = { version = "0.31.3", optional = true }
Expand Down
1 change: 1 addition & 0 deletions src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

/// A struct representing a color with red, green, blue, and alpha components.
/// Each component is stored as a float.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, PartialEq, Clone, Copy)]
pub struct Color
{
Expand Down
1 change: 1 addition & 0 deletions src/dimen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub type UVec2 = Vector2<u32>;
/// A vector containing two numeric values. This may represent a size or
/// position.
#[repr(C)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(PartialEq, Eq, Clone, Copy, Hash, Debug)]
pub struct Vector2<T>
{
Expand Down
6 changes: 6 additions & 0 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ impl WindowStartupInfo

/// Identifies a mouse button.
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub enum MouseButton
{
Expand All @@ -739,6 +740,7 @@ pub enum MouseButton

/// Describes a difference in the mouse scroll wheel position.
#[derive(Debug, PartialEq, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum MouseScrollDistance
{
/// Number of lines or rows to scroll in each direction. The `y` field
Expand Down Expand Up @@ -787,6 +789,7 @@ pub enum MouseScrollDistance

/// A virtual key code.
#[allow(missing_docs)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Hash, Ord, PartialOrd, PartialEq, Eq, Clone, Copy)]
#[non_exhaustive]
pub enum VirtualKeyCode
Expand Down Expand Up @@ -1033,6 +1036,7 @@ pub(crate) enum WindowCreationMode

/// The size of the window to create.
#[derive(Debug, PartialEq, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum WindowSize
{
/// Define the window size in pixels.
Expand All @@ -1049,6 +1053,7 @@ pub enum WindowSize

/// The position of the window to create.
#[derive(Debug, Hash, PartialEq, Eq, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum WindowPosition
{
/// Place the window in the center of the primary monitor.
Expand All @@ -1060,6 +1065,7 @@ pub enum WindowPosition

/// Whether or not the window is in fullscreen mode.
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum WindowFullscreenMode
{
/// Non-fullscreen mode.
Expand Down