fn read_event(dev: &mut Device) -> io::Result<Event_>
    {
        // There are several transmutes here.
        // transumte does require both types have the same 
        
        // This is kinda gross, but it saves me from manually
        // implementing an iterator (TODO!).
        const EVENT_BYTES: usize = 32;
        let mut buf = [0; EVENT_BYTES];
        
        let n = try!(dev.fd.read(&mut buf[..]));
        if n == 0 {
            return Err(io::Error::new(io::ErrorKind::WouldBlock, "no events available"));
        }
        // TODO: do something smarter than panicing.
        // (Future versions of drm might add smaller events).
        // (We don't get partial events. DRM guarantess that).
        assert_eq!(EVENT_BYTES, n);

        let ev: ffi::event_vblank = unsafe {
            transmute(buf)
        };

        let type_ = match ev.base.type_ {
            consts::DRM_EVENT_VBLANK => EventType::VBlank,
            consts::DRM_EVENT_FLIP_COMPLETE => EventType::FlipComplete,
            _ => return Err(io::Error::new(io::ErrorKind::InvalidData,
                                           "Unknow DRM event type")),
        };

        // Well... std::time::Instant is nice.
        // There's no nice way to create one.
        let at: Instant = unsafe {
            transmute(libc::timespec { tv_sec: ev.tv_sec as i64,
                                       tv_nsec: ev.tv_usec as i64 * 1000 })
        };

        println!("current instant: {:?}", Instant::now());
        println!("   evil instant: {:?}", at);

        // // Calling this will check if at is in the past.
        // // Otherwise it will panic.
        // at.elapsed();
        
        // Turns out that always panics: my driver returns vblank
        // events from the Future.  I'm assuming that the driver is
        // returned the time vblank actually occurs. But the event is
        // sent before it occurs. 

        Ok(Event_ {
            type_: type_,
            user_data: ev.user_data,
            time: at,
            sequence: ev.sequence,
        })
    }
/// Read the next event on the socket.
///
/// This reads a single event from the socket returns it.
/// This requires mut because:
///
/// * Consuming an event could cause problems if done in multiple places
///   as mut guarentees on aliasing, we can safely read it.
/// * &mut is required for calling Read::read.
Read the next event on the socket.
This reads a single event from the socket returns it.
This requires mut because.

Consuming an event could cause problems if done in multiple places
as mut guarentees on aliasing, we can safely read it.
&mut is required for calling Read::read.
Read the next event on the socket . This reads a single event from the socket returns it . This requires mut because . Consuming an event could cause problems if done in multiple places as mut guarentees on aliasing we can safely read it . &mut is required for calling Read :: read .
fn read_event(dev: &mut Device) -> io::Result<Event_>
    {
        // There are several transmutes here.
        // transumte does require both types have the same 
        // This is kinda gross, but it saves me from manually
        // implementing an iterator (TODO!).
        const EVENT_BYTES: usize = 32;
        let mut buf = [0; EVENT_BYTES];
        let n = try!(dev.fd.read(&mut buf[..]));
        if n == 0 {
            return Err(io::Error::new(io::ErrorKind::WouldBlock, "no events available"));
        }
        // TODO: do something smarter than panicing.
        // (Future versions of drm might add smaller events).
        // (We don't get partial events. DRM guarantess that).
        assert_eq!(EVENT_BYTES, n);
        let ev: ffi::event_vblank = unsafe {
            transmute(buf)
        };
        let type_ = match ev.base.type_ {
            consts::DRM_EVENT_VBLANK => EventType::VBlank,
            consts::DRM_EVENT_FLIP_COMPLETE => EventType::FlipComplete,
            _ => return Err(io::Error::new(io::ErrorKind::InvalidData,
                                           "Unknow DRM event type")),
        };
        // Well... std::time::Instant is nice.
        // There's no nice way to create one.
        let at: Instant = unsafe {
            transmute(libc::timespec { tv_sec: ev.tv_sec as i64,
                                       tv_nsec: ev.tv_usec as i64 * 1000 })
        };
        println!("current instant: {:?}", Instant::now());
        println!("   evil instant: {:?}", at);
        // // Calling this will check if at is in the past.
        // // Otherwise it will panic.
        // at.elapsed();
        // Turns out that always panics: my driver returns vblank
        // events from the Future.  I'm assuming that the driver is
        // returned the time vblank actually occurs. But the event is
        // sent before it occurs. 
        Ok(Event_ {
            type_: type_,
            user_data: ev.user_data,
            time: at,
            sequence: ev.sequence,
        })
    }
fn read_event ( dev : & mut Device ) -> io :: Result < Event_ > { // There are several transmutes here. // transumte does require both types have the same  // This is kinda gross, but it saves me from manually // implementing an iterator (TODO!). const EVENT_BYTES : usize = 32 ; let mut buf = [ 0 ; EVENT_BYTES ] ; let n = try ! ( dev fd read ( mut buf [ ] ) ) ; if n == 0 { return Err ( io :: Error :: new ( io :: ErrorKind :: WouldBlock , " " ) ) ; } // TODO: do something smarter than panicing. // (Future versions of drm might add smaller events). // (We don't get partial events. DRM guarantess that). assert_eq ! ( EVENT_BYTES n ) ; let ev : ffi :: event_vblank = unsafe { transmute ( buf ) } ; let type_ = match ev . base . type_ { consts :: DRM_EVENT_VBLANK => EventType :: VBlank , consts :: DRM_EVENT_FLIP_COMPLETE => EventType :: FlipComplete , _ => return Err ( io :: Error :: new ( io :: ErrorKind :: InvalidData , " " ) ) , } ; // Well... std::time::Instant is nice. // There's no nice way to create one. let at : Instant = unsafe { transmute ( libc :: timespec { tv_sec : ev . tv_sec as i64 , tv_nsec : ev . tv_usec as i64 * 1000 } ) } ; println ! ( " " Instant now ( ) ) ; println ! ( " " at ) ; // // Calling this will check if at is in the past. // // Otherwise it will panic. // at.elapsed(); // Turns out that always panics: my driver returns vblank // events from the Future.  I'm assuming that the driver is // returned the time vblank actually occurs. But the event is // sent before it occurs.  Ok ( Event_ { type_ : type_ , user_data : ev . user_data , time : at , sequence : ev . sequence , } ) }
Read the next event on the socket.
Read the next event on the socket .
dev
&mut Device