diff --git a/src/object.rs b/src/object.rs index 21601156e..3a54ea25c 100644 --- a/src/object.rs +++ b/src/object.rs @@ -4,7 +4,6 @@ crate mod desc; crate mod dict; crate mod files; crate mod process; -crate mod serialization; crate mod types; crate use base::{Primitive, Value}; diff --git a/src/object/base.rs b/src/object/base.rs index 337b223e9..e61e612ed 100644 --- a/src/object/base.rs +++ b/src/object/base.rs @@ -44,26 +44,6 @@ pub enum Primitive { EndOfStream, } -/* -impl Serialize for Primitive { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - match self { - Primitive::Nothing => serializer.serialize_i32(0), - Primitive::EndOfStream => serializer.serialize_i32(0), - Primitive::Int(i) => serializer.serialize_i64(*i), - Primitive::Float(OF64 { inner: f }) => serializer.serialize_f64(f.into_inner()), - Primitive::Bytes(b) => serializer.serialize_u128(*b), - Primitive::String(ref s) => serializer.serialize_str(s), - Primitive::Boolean(b) => serializer.serialize_bool(*b), - Primitive::Date(d) => serializer.serialize_str(&d.to_string()), - } - } -} -*/ - impl Primitive { crate fn type_name(&self) -> String { use Primitive::*; diff --git a/src/object/serialization.rs b/src/object/serialization.rs deleted file mode 100644 index 8addd565f..000000000 --- a/src/object/serialization.rs +++ /dev/null @@ -1,117 +0,0 @@ -use crate::object::base::OF64; -use crate::prelude::*; - -use ordered_float::OrderedFloat; -use serde::de::{self, Visitor}; -use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use std::fmt; - -struct OF64Visitor; - -impl Visitor<'_> for OF64Visitor { - type Value = OF64; - - fn visit_f64(self, value: f64) -> Result { - Ok(OF64::new(OrderedFloat(value))) - } - - fn visit_f32(self, value: f32) -> Result { - Ok(OF64::new(OrderedFloat(value as f64))) - } - - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("a float") - } -} - -/* -impl<'de> Deserialize<'de> for OF64 { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - deserializer.deserialize_f64(OF64Visitor) - } -} -*/ - -/* -impl Serialize for Value { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - match self { - Value::Primitive(p) => p.serialize(serializer), - Value::Object(o) => o.serialize(serializer), - Value::List(l) => l.serialize(serializer), - Value::Block(b) => b.serialize(serializer), - Value::Error(e) => e.serialize(serializer), - Value::Filesystem => "".serialize(serializer), - } - } -} -*/ -struct ValueVisitor; - -impl<'de> Visitor<'de> for ValueVisitor { - type Value = Value; - - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("a shell value") - } - - fn visit_i32(self, value: i32) -> Result - where - E: de::Error, - { - Ok(Value::int(value)) - } - - fn visit_i64(self, value: i64) -> Result - where - E: de::Error, - { - Ok(Value::int(value)) - } - - fn visit_u32(self, value: u32) -> Result - where - E: de::Error, - { - Ok(Value::int(value)) - } - - fn visit_u64(self, value: u64) -> Result - where - E: de::Error, - { - // TODO: Handle overflow better - Ok(Value::int(value as i64)) - } - - fn visit_str(self, value: &str) -> Result - where - E: de::Error, - { - Ok(Value::string(value)) - } - - fn visit_bool(self, value: bool) -> Result - where - E: de::Error, - { - Ok(Value::boolean(value)) - } -} - -/* -impl<'de> Deserialize<'de> for Value { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - deserializer.deserialize_any(ValueVisitor) - } -} -*/