Implement Error for SDL Error.

This commit is contained in:
Kyle Strohbeck
2016-12-09 13:32:20 -06:00
parent 1a10323e15
commit f630e25c6c
+15
View File
@@ -1,3 +1,4 @@
use std::error;
use std::ffi::{CStr, CString, NulError};
use std::fmt;
use std::rc::Rc;
@@ -28,6 +29,20 @@ impl fmt::Display for Error {
}
}
impl error::Error for Error {
fn description(&self) -> &str {
use self::Error::*;
match *self {
NoMemError => "out of memory",
ReadError => "error reading from datastream",
WriteError => "error writing to datastream",
SeekError => "error seeking in datastream",
UnsupportedError => "unknown SDL error"
}
}
}
use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT};
/// Only one Sdl context can be alive at a time.
/// Set to false by default (not alive).