Created
February 2, 2015 20:29
-
-
Save rrichardson/66add0d754707d71de3d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub struct DropCopyProto; | |
impl Protocol for DropCopyProto { | |
type Output = DropCopy; | |
fn new() -> DropCopyProto { | |
DropCopyProto | |
} | |
fn append(&mut self, buf: &AROIobuf) -> Option<(<Self as Protocol>::Output, AROIobuf, u32)> { | |
let size = mem::size_of::<DropCopy>() as u32; | |
if buf.len() >= size { | |
let (a, b) = buf.split_at(size).unwrap(); | |
let val = unsafe { *(mem::transmute::<*mut u8, *const DropCopy>(a.ptr())) }; | |
Some((val, b, size)) | |
} else { | |
None | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment