summaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
authorFabian Freyer <fabian.freyer@physik.tu-berlin.de>2022-02-08 22:17:59 +0100
committerKyle Martin <krm504@nyu.edu>2022-02-08 16:30:16 -0500
commit003085beeec4a3d516dd859ee59aeccb3f16426f (patch)
tree897db1ae26a9da39cebcba5b1e0c15aec425c3a3 /rust
parent1ea29a230051c2413120e0436bd9dd339dd1c2f5 (diff)
rust: Move icon and name setter to TagType::create
Diffstat (limited to 'rust')
-rw-r--r--rust/src/binaryview.rs11
-rw-r--r--rust/src/tags.rs11
2 files changed, 11 insertions, 11 deletions
diff --git a/rust/src/binaryview.rs b/rust/src/binaryview.rs
index 15f3030c..00069c15 100644
--- a/rust/src/binaryview.rs
+++ b/rust/src/binaryview.rs
@@ -679,9 +679,7 @@ pub trait BinaryViewExt: BinaryViewBase {
name: N,
icon: I,
) -> Ref<TagType> {
- let tag_type = TagType::create(self.as_ref());
- tag_type.set_name(name);
- tag_type.set_icon(icon);
+ let tag_type = TagType::create(self.as_ref(), name, icon);
unsafe {
BNAddTagType(self.as_ref().handle, tag_type.handle);
}
@@ -726,12 +724,7 @@ pub trait BinaryViewExt: BinaryViewBase {
}
}
- fn create_tag<S: BnStrCompatible>(
- &self,
- t: &TagType,
- data: S,
- user: bool,
- ) -> Ref<Tag> {
+ fn create_tag<S: BnStrCompatible>(&self, t: &TagType, data: S, user: bool) -> Ref<Tag> {
let tag = Tag::new(t, data);
unsafe { BNAddTag(self.as_ref().handle, tag.handle, user) }
tag
diff --git a/rust/src/tags.rs b/rust/src/tags.rs
index eddcc5f0..ac66b279 100644
--- a/rust/src/tags.rs
+++ b/rust/src/tags.rs
@@ -83,8 +83,15 @@ impl TagType {
Ref::new(Self { handle })
}
- pub(crate) fn create(view: &BinaryView) -> Ref<Self> {
- unsafe { Self::from_raw(BNCreateTagType(view.handle)) }
+ pub fn create<N: BnStrCompatible, I: BnStrCompatible>(
+ view: &BinaryView,
+ name: N,
+ icon: I,
+ ) -> Ref<Self> {
+ let tag_type = unsafe { Self::from_raw(BNCreateTagType(view.handle)) };
+ tag_type.set_name(name);
+ tag_type.set_icon(icon);
+ tag_type
}
pub fn id(&self) -> BnString {