From b6876f9df6e3119331fac01c0bc954ca9f3c798b Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sun, 5 Apr 2026 20:33:57 +0800 Subject: Add general renderer support with serialization formats --- mingling_core/src/any.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'mingling_core/src/any.rs') diff --git a/mingling_core/src/any.rs b/mingling_core/src/any.rs index d550ec7..57eddfb 100644 --- a/mingling_core/src/any.rs +++ b/mingling_core/src/any.rs @@ -23,7 +23,7 @@ pub struct AnyOutput where G: Display, { - inner: Box, + pub(crate) inner: Box, pub type_id: std::any::TypeId, pub member_id: G, } @@ -81,6 +81,19 @@ where pub fn route_renderer(self) -> ChainProcess { ChainProcess::Ok((self, Next::Renderer)) } + + #[cfg(feature = "general_renderer")] + /// Restore AnyOutput back to the original Serialize type + pub fn restore(self) -> Option { + if self.type_id == std::any::TypeId::of::() { + match self.inner.downcast::() { + Ok(boxed) => Some(*boxed), + Err(_) => None, + } + } else { + None + } + } } impl std::ops::Deref for AnyOutput -- cgit