From 94af6929abac4b30b984ffa403a3f7277c77ddd4 Mon Sep 17 00:00:00 2001 From: emilis Date: Sat, 5 Nov 2022 10:42:52 +0000 Subject: [PATCH] Fixed expand not working with deseralization of full objects instead of iris --- src/astreams/serde_ext.rs | 24 ++++++++++++------------ src/main.rs | 1 + 2 files changed, 13 insertions(+), 12 deletions(-) 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;