use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; static CONTEXT: Lazy> = Lazy::new(|| { serde_json::from_str(include_str!("../assets/lemmy/context.json")).expect("parse context") }); #[derive(Serialize, Deserialize, Debug)] pub(crate) struct WithContext { #[serde(rename = "@context")] context: Vec, #[serde(flatten)] inner: T, } impl WithContext { pub(crate) fn new(inner: T) -> WithContext { WithContext { context: (*CONTEXT).clone(), inner, } } pub(crate) fn inner(self) -> T { self.inner } }