summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml7
-rw-r--r--src/lib.rs14
2 files changed, 21 insertions, 0 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 93c69b3..e1165e3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,7 +11,14 @@ A rust pic24 decoder
[dependencies]
yaxpeax-arch = { path = "../../yaxpeax-arch" }
+"serde" = "*"
+"serde_derive" = "*"
[[test]]
name = "test"
path = "test/test.rs"
+
+[features]
+default = []
+
+use-serde = []
diff --git a/src/lib.rs b/src/lib.rs
index 2da8e1f..c800e20 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,3 +1,10 @@
+#[cfg(feature="use-serde")]
+#[macro_use] extern crate serde_derive;
+#[cfg(feature="use-serde")]
+extern crate serde;
+#[cfg(feature="use-serde")]
+use serde::{Serialize, Deserialize};
+
extern crate yaxpeax_arch;
use yaxpeax_arch::{Arch, Decodable, LengthedInstruction};
@@ -41,7 +48,14 @@ impl Decodable for Instruction {
}
}
+#[cfg(feature="use-serde")]
+#[derive(Debug, Serialize, Deserialize)]
pub struct PIC24;
+
+#[cfg(not(feature="use-serde"))]
+#[derive(Debug)]
+pub struct PIC24;
+
impl Arch for PIC24 {
type Address = u32;
type Instruction = Instruction;