From e1277f07f4c273630ecd936b86102dc8461e19c2 Mon Sep 17 00:00:00 2001 From: c-to-the-l <39165068+c-to-the-l@users.noreply.github.com> Date: Tue, 23 Jan 2024 03:23:16 +0000 Subject: [PATCH] fix serialize feature flag --- src/lib.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 65872a7..885b522 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,6 +53,9 @@ extern crate serde_derive; use serde::de::*; use serde::Deserializer; +#[cfg(feature = "serialize")] +use serde::{Serialize, Serializer}; + use std::fmt; use std::io; @@ -210,6 +213,20 @@ impl fmt::Display for Mode { } } +#[cfg(feature = "serialize")] +impl Serialize for Mode { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Mode::NoFix => serializer.serialize_i32(1), + Mode::Fix2d => serializer.serialize_i32(2), + Mode::Fix3d => serializer.serialize_i32(3), + } + } +} + fn mode_from_str<'de, D>(deserializer: D) -> Result where D: Deserializer<'de>,