use crate::extensions::{ExtensionDispatcher, WidgetExtension};
pub struct PlushieAppBuilder {
extensions: Vec<Box<dyn WidgetExtension>>,
}
impl std::fmt::Debug for PlushieAppBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("PlushieAppBuilder")
.field("extensions", &self.extensions.len())
.finish()
}
}
impl PlushieAppBuilder {
pub fn new() -> Self {
Self { extensions: vec![] }
}
pub fn extension(mut self, ext: impl WidgetExtension + 'static) -> Self {
self.extensions.push(Box::new(ext));
self
}
pub fn extension_boxed(mut self, ext: Box<dyn WidgetExtension>) -> Self {
self.extensions.push(ext);
self
}
pub fn extension_keys(&self) -> Vec<&str> {
self.extensions.iter().map(|e| e.config_key()).collect()
}
pub fn build_dispatcher(self) -> ExtensionDispatcher {
ExtensionDispatcher::new(self.extensions)
}
}
impl Default for PlushieAppBuilder {
fn default() -> Self {
Self::new()
}
}