use rspack_error::Diagnostic;
use crate::{ContextOptions, ContextTypePrefix, Dependency};
pub trait ContextDependency: Dependency {
fn request(&self) -> &str;
fn options(&self) -> &ContextOptions;
fn get_context(&self) -> Option<&str>;
fn resource_identifier(&self) -> &str;
fn get_optional(&self) -> bool {
false
}
fn type_prefix(&self) -> ContextTypePrefix;
fn critical(&self) -> Option<Diagnostic>;
fn set_critical(&self, critical: Option<Diagnostic>);
}
pub trait AsContextDependency {
fn as_context_dependency(&self) -> Option<&dyn ContextDependency> {
None
}
}
impl<T: ContextDependency> AsContextDependency for T {
fn as_context_dependency(&self) -> Option<&dyn ContextDependency> {
Some(self)
}
}