pub trait FromByteCode {
// Required method
fn from_byte_code(_: &mut dyn Read) -> Self;
}
Expand description
Required Methods§
Sourcefn from_byte_code(_: &mut dyn Read) -> Self
fn from_byte_code(_: &mut dyn Read) -> Self
Convert from MsgPack to your type.
This function takes a mutable reference of type Read
and returns your
operand type.
§Example
#[derive(PartialEq, Debug)]
struct Operand(i64);
impl FromByteCode for Operand {
fn from_byte_code(mut buf: &mut Read) -> Operand {
let value = rmp::decode::read_int(&mut buf).unwrap();
Operand(value)
}
}
let bytecode = [0xd];
assert_eq!(Operand(13), Operand::from_byte_code(&mut &bytecode[..]));
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.