Fixed expand not working with deseralization of full objects instead of iris

This commit is contained in:
emilis 2022-11-05 10:42:52 +00:00
parent bd93207c25
commit 94af6929ab
2 changed files with 13 additions and 12 deletions

View File

@ -2,6 +2,8 @@ use super::resolve::Resolver;
use std::{fmt, marker::PhantomData}; use std::{fmt, marker::PhantomData};
use serde::{de::Visitor, Deserialize, Deserializer}; use serde::{de::Visitor, Deserialize, Deserializer};
static TYPE_STR: &str = std::any::type_name::<&str>();
static TYPE_STRING: &str = std::any::type_name::<String>();
// Allows a value that's a string to be expanded into an object AND the serialization of that object itself // 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 // TODO: deserializing the actual object isnt supported atm LOL
@ -26,13 +28,6 @@ where
formatter.write_str(std::any::type_name::<Out>()) formatter.write_str(std::any::type_name::<Out>())
} }
fn visit_map<A>(self, map: A) -> Result<Self::Value, A::Error>
where
A: serde::de::MapAccess<'de>,
{
todo!()
}
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E> fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
where where
E: serde::de::Error, E: serde::de::Error,
@ -48,7 +43,7 @@ where
), ),
&name, &name,
) )
}) // TODO try this error })
} }
fn visit_seq<S>(self, visitor: S) -> Result<Self::Value, S::Error> fn visit_seq<S>(self, visitor: S) -> Result<Self::Value, S::Error>
@ -59,10 +54,15 @@ where
} }
} }
deserializer.deserialize_any(ResolveVisitor { let type_name = std::any::type_name::<Out>();
resolver: resolver, if type_name == TYPE_STR || type_name == TYPE_STRING {
_type: PhantomData, deserializer.deserialize_any(ResolveVisitor {
}) resolver: resolver,
_type: PhantomData,
})
} else {
Out::deserialize(deserializer)
}
} }
// Allows deserialization of a single item into a vector of that item // Allows deserialization of a single item into a vector of that item

View File

@ -1,3 +1,4 @@
#![feature(const_type_name)]
#![feature(let_chains)] #![feature(let_chains)]
mod astreams; mod astreams;
mod database; mod database;