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 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
// TODO: deserializing the actual object isnt supported atm LOL
@ -26,13 +28,6 @@ where
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>
where
E: serde::de::Error,
@ -48,7 +43,7 @@ where
),
&name,
)
}) // TODO try this error
})
}
fn visit_seq<S>(self, visitor: S) -> Result<Self::Value, S::Error>
@ -59,10 +54,15 @@ where
}
}
deserializer.deserialize_any(ResolveVisitor {
resolver: resolver,
_type: PhantomData,
})
let type_name = std::any::type_name::<Out>();
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

View File

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