sheave_core/messages/
inconsistent_command.rsuse std::{
error::Error,
fmt::{
Display,
Formatter,
Result as FormatResult
},
io::{
Error as IOError,
ErrorKind
}
};
use crate::messages::amf::v0::AmfString;
#[derive(Debug)]
pub struct InconsistentCommand {
expected: AmfString,
actual: AmfString
}
impl InconsistentCommand {
pub fn new(expected: AmfString, actual: AmfString) -> Self {
Self { expected, actual }
}
}
impl Display for InconsistentCommand {
fn fmt(&self, f: &mut Formatter<'_>) -> FormatResult {
writeln!(f, "Command name is inconsistent. expected: {}, actual: {}", self.expected, self.actual)
}
}
impl Error for InconsistentCommand {}
pub fn inconsistent_command(expected: &str, actual: AmfString) -> IOError {
IOError::new(
ErrorKind::InvalidData,
InconsistentCommand {
expected: AmfString::from(expected),
actual
}
)
}