diff --git a/src/astreams/serde_ext.rs b/src/astreams/serde_ext.rs index 0702757..a77c715 100644 --- a/src/astreams/serde_ext.rs +++ b/src/astreams/serde_ext.rs @@ -2,6 +2,8 @@ use super::resolve::Resolver; use std::{fmt, marker::PhantomData}; use serde::{de::Visitor, Deserialize, Deserializer}; +static TYPE_STR: &str = std::any::type_name::<&str>(); +static TYPE_STRING: &str = std::any::type_name::(); // Allows a value that's a string to be expanded into an object AND the serialization of that object itself // TODO: deserializing the actual object isnt supported atm LOL @@ -26,13 +28,6 @@ where formatter.write_str(std::any::type_name::()) } - fn visit_map(self, map: A) -> Result - where - A: serde::de::MapAccess<'de>, - { - todo!() - } - fn visit_str(self, value: &str) -> Result where E: serde::de::Error, @@ -48,7 +43,7 @@ where ), &name, ) - }) // TODO try this error + }) } fn visit_seq(self, visitor: S) -> Result @@ -59,10 +54,15 @@ where } } - deserializer.deserialize_any(ResolveVisitor { - resolver: resolver, - _type: PhantomData, - }) + let type_name = std::any::type_name::(); + if type_name == TYPE_STR || type_name == TYPE_STRING { + deserializer.deserialize_any(ResolveVisitor { + resolver: resolver, + _type: PhantomData, + }) + } else { + Out::deserialize(deserializer) + } } // Allows deserialization of a single item into a vector of that item diff --git a/src/main.rs b/src/main.rs index 0cd4a7a..049932a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +#![feature(const_type_name)] #![feature(let_chains)] mod astreams; mod database;