sim: Move 'Flash' into a trait

Make 'Flash' a trait, and move the current functionality into a type
called 'SimFlash'.  The code that runs the simulation only uses the
trait.

Signed-off-by: David Brown <david.brown@linaro.org>
diff --git a/sim/src/api.rs b/sim/src/api.rs
index 7b81627..2fa6b31 100644
--- a/sim/src/api.rs
+++ b/sim/src/api.rs
@@ -3,6 +3,7 @@
 use flash::{Result, Flash};
 use libc;
 use log::LogLevel;
+use mem;
 use std::slice;
 
 // The current active flash device.  The 'static is a lie, and we manage the lifetime ourselves.
@@ -10,7 +11,8 @@
 
 // Set the flash device to be used by the simulation.  The pointer is unsafely stashed away.
 pub unsafe fn set_flash(dev: &mut Flash) {
-    FLASH = Some(dev);
+    let dev: &'static mut Flash = mem::transmute(dev);
+    FLASH = Some(dev as *mut Flash);
 }
 
 pub unsafe fn clear_flash() {