From a5732460bceba99e985b9d2483d7dbdeb981e56f Mon Sep 17 00:00:00 2001 From: Cassie Jones Date: Sat, 11 Jan 2020 01:50:31 -0500 Subject: [PATCH] Add encode and decode traits --- toolchain/src/inst.rs | 3 +++ toolchain/src/inst/decode.rs | 5 +++++ toolchain/src/inst/encode.rs | 5 +++++ 3 files changed, 13 insertions(+) create mode 100644 toolchain/src/inst/decode.rs create mode 100644 toolchain/src/inst/encode.rs diff --git a/toolchain/src/inst.rs b/toolchain/src/inst.rs index db8c939..fea8ed6 100644 --- a/toolchain/src/inst.rs +++ b/toolchain/src/inst.rs @@ -1,3 +1,6 @@ +pub mod decode; +pub mod encode; + #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct Reg(u8); diff --git a/toolchain/src/inst/decode.rs b/toolchain/src/inst/decode.rs new file mode 100644 index 0000000..cb9b6a4 --- /dev/null +++ b/toolchain/src/inst/decode.rs @@ -0,0 +1,5 @@ +use std::io::{self, Read}; + +pub trait Decode: Sized { + fn decode(reader: &mut impl Read) -> io::Result>; +} diff --git a/toolchain/src/inst/encode.rs b/toolchain/src/inst/encode.rs new file mode 100644 index 0000000..085751d --- /dev/null +++ b/toolchain/src/inst/encode.rs @@ -0,0 +1,5 @@ +use std::io::{self, Write}; + +pub trait Encode { + fn encode(&self, writer: &mut impl Write) -> io::Result<()>; +} -- 2.47.0