use super::run_import::DomImportContext;
use super::sel::CompiledSelector;
use crate::LexicalError;
use crate::dom::DomNode;
use crate::node::NodeRef;
use std::rc::Rc;
pub type ImportNext<'a> = &'a dyn Fn() -> Result<Vec<NodeRef>, LexicalError>;
pub type DomImportFn =
Rc<dyn Fn(&DomImportContext, &DomNode, ImportNext<'_>) -> Result<Vec<NodeRef>, LexicalError>>;
#[derive(Clone)]
pub struct DomImportRule {
pub name: Option<String>,
pub match_: CompiledSelector,
pub import: DomImportFn,
}
pub fn define_import_rule(
name: Option<&str>,
match_: CompiledSelector,
import: impl Fn(&DomImportContext, &DomNode, ImportNext<'_>) -> Result<Vec<NodeRef>, LexicalError>
+ 'static,
) -> DomImportRule {
DomImportRule {
name: name.map(str::to_owned),
match_,
import: Rc::new(import),
}
}