summaryrefslogtreecommitdiff
path: root/plugins/warp/src/convert.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-05-07 19:22:21 -0400
committerMason Reed <35282038+emesare@users.noreply.github.com>2025-05-12 17:45:24 -0400
commit2f214f6c9935e8ce8df4732cde44a540a003258c (patch)
tree6fe319433ef0d2ad75fcc58a50eaa632bb627ec9 /plugins/warp/src/convert.rs
parentb4cf0be8816182c9efca037e27e9439482f8bf36 (diff)
[Rust] Reduce usage of `IntoCStr` in function signatures
This is being done to reduce complexity in function signatures, specifically many of the strings we are passing ultimately should be new types themselves instead of "just strings", things such as type ids. Another place which was confusing was dealing with filesystem related APIs, this commit turns most of those params into a stricter `Path` type. This is bringing the rust api more inline with both python and C++, where the wrapper eagerly converts the string into the languages standard string type. Special consideration must be made for symbols or other possible non utf-8 objects. This commit will be followed up with one that adds the `IntoCStr` bound on API's we want to keep as invalid utf-8 so we can for example, get section by name on a section with invalid utf-8.
Diffstat (limited to 'plugins/warp/src/convert.rs')
-rw-r--r--plugins/warp/src/convert.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/plugins/warp/src/convert.rs b/plugins/warp/src/convert.rs
index 2e0fb3f1..b6c2f7b4 100644
--- a/plugins/warp/src/convert.rs
+++ b/plugins/warp/src/convert.rs
@@ -431,7 +431,7 @@ pub fn to_bn_type<A: BNArchitecture>(arch: &A, ty: &Type) -> BNRef<BNType> {
let base_struct_ntr = match c.guid {
Some(guid) => BNNamedTypeReference::new_with_id(
NamedTypeReferenceClass::UnknownNamedTypeClass,
- guid.to_string(),
+ &guid.to_string(),
base_struct_ntr_name,
),
None => BNNamedTypeReference::new(
@@ -475,7 +475,7 @@ pub fn to_bn_type<A: BNArchitecture>(arch: &A, ty: &Type) -> BNRef<BNType> {
// TODO: Add default name?
let member_name = member.name.to_owned().unwrap_or("enum_VAL".into());
let member_value = member.constant;
- builder.insert(member_name, member_value);
+ builder.insert(&member_name, member_value);
}
// TODO: Warn if enumeration has no size.
let width = bits_to_bytes(c.member_type.size().unwrap()) as usize;
@@ -545,7 +545,7 @@ pub fn to_bn_type<A: BNArchitecture>(arch: &A, ty: &Type) -> BNRef<BNType> {
let ntr_name = c.name.to_owned().unwrap_or(guid_str.clone());
NamedTypeReference::new_with_id(
NamedTypeReferenceClass::UnknownNamedTypeClass,
- guid_str,
+ &guid_str,
ntr_name,
)
}