use crate::prelude::*; use std::borrow::Cow; pub struct Dehydrate where T: Component + serde::Serialize + serde::de::DeserializeOwned, { id: Cow<'static, str>, component: T, } impl Dehydrate where T: Component + serde::Serialize + serde::de::DeserializeOwned, { pub fn new(id: impl Into>, component: T) -> Dehydrate { Dehydrate { id: id.into(), component, } } } impl Component for Dehydrate where T: Component + serde::Serialize + serde::de::DeserializeOwned, { fn into_node(self) -> Node { div() .id(self.id) .attribute( "data-component", serde_json::to_string(&self.component).unwrap(), ) .child(self.component) .into_node() } }