Implement Display for UpdateTextureError.

This commit is contained in:
Kyle Strohbeck
2016-12-09 12:11:42 -06:00
parent 74ea28062f
commit fcf43c5166
+26
View File
@@ -1043,6 +1043,32 @@ pub enum UpdateTextureError {
SdlError(String),
}
impl fmt::Display for UpdateTextureError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use self::UpdateTextureError::*;
match *self {
PitchOverflows(value) => write!(f, "Pitch overflows ({})", value),
PitchMustBeMultipleOfTwoForFormat(value, format) => write!(f,
"Pitch must be multiple of two for pixel format '{:?}' ({})",
format, value),
XMustBeMultipleOfTwoForFormat(value, format) => write!(f,
"X must be multiple of two for pixel format '{:?}' ({})",
format, value),
YMustBeMultipleOfTwoForFormat(value, format) => write!(f,
"Y must be multiple of two for pixel format '{:?}' ({})",
format, value),
WidthMustBeMultipleOfTwoForFormat(value, format) => write!(f,
"Width must be multiple of two for pixel format '{:?}' ({})",
format, value),
HeightMustBeMultipleOfTwoForFormat(value, format) => write!(f,
"Height must be multiple of two for pixel format '{:?}' ({})",
format, value),
SdlError(ref e) => write!(f, "SDL error: {}", e)
}
}
}
#[derive(Debug)]
pub enum UpdateTextureYUVError {
PitchOverflows { plane: &'static str, value: usize },