Skip to content

Commit 7ac2d2d

Browse files
committed
added register_traits method
1 parent 20ac4b4 commit 7ac2d2d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

program/rust/build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ fn main() {
1414
parser.register_traits("pc_price_info", borsh_derives.to_vec());
1515
parser.register_traits("cmd_upd_price", borsh_derives.to_vec());
1616

17-
1817
//generate and write bindings
1918
let bindings = Builder::default()
2019
.header("./src/bindings.h")

program/rust/build_utils.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ impl<'a> DeriveAdderParserCallback<'a> {
2424
}
2525
}
2626

27+
impl<'a> DeriveAdderParserCallback<'a> {
28+
///create a parser that does not add any traits
29+
pub fn new() -> Self {
30+
Default::default()
31+
}
32+
//add pairs of types and their desired traits
33+
pub fn register_traits(&mut self, type_name: &'a str, traits: Vec<String>) {
34+
self.types_to_traits.insert(&type_name, traits);
35+
}
36+
}
37+
2738
//this is required to implement the callback trait
2839
impl UnwindSafe for DeriveAdderParserCallback<'_> {}
2940

0 commit comments

Comments
 (0)