use super::Error;
#[derive(Debug)]
pub(super) struct UnsupportedFeature {
message: Box<str>,
}
impl std::error::Error for UnsupportedFeature {}
impl core::fmt::Display for UnsupportedFeature {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "unsupported feature: {}", self.message)
}
}
impl Error {
pub fn unsupported_feature(message: impl Into<String>) -> Error {
Error::from(super::ErrorKind::UnsupportedFeature(UnsupportedFeature {
message: message.into().into(),
}))
}
pub fn is_unsupported_feature(&self) -> bool {
matches!(self.kind(), super::ErrorKind::UnsupportedFeature(_))
}
}