use std::{fmt, ops::Deref, path::PathBuf}; use rlua::{Lua, RegistryKey}; #[derive(Debug)] pub struct InstanceSnapshotContext { /// Empty struct that will be used later to fill out required Lua state for /// user plugins. pub plugin_context: Option, } impl Default for InstanceSnapshotContext { fn default() -> Self { Self { plugin_context: None, } } } #[derive(Debug)] pub struct SnapshotPluginContext { pub state: IgnoreDebug, /// Paths to the user plugins files. These paths are generated by the root /// project file, if there is one. pub plugin_paths: Vec, /// Lazy-initialized registry keys pointing to the values returned by each /// user plugin. When processing user plugins, these should be applied in /// order. pub plugin_functions: Option>, } impl SnapshotPluginContext { pub fn new(plugin_paths: Vec) -> Self { Self { state: IgnoreDebug(Lua::new()), plugin_paths, plugin_functions: None, } } } /// Utility type to enable having a field of a struct not implement Debug and /// instead show a placeholder. #[derive(Clone)] pub struct IgnoreDebug(pub T); impl fmt::Debug for IgnoreDebug { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { write!(formatter, "") } } impl Deref for IgnoreDebug { type Target = T; fn deref(&self) -> &T { &self.0 } } pub struct ImfsSnapshotContext;