summaryrefslogtreecommitdiff
path: root/rust/src/platform.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 /rust/src/platform.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 'rust/src/platform.rs')
-rw-r--r--rust/src/platform.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/rust/src/platform.rs b/rust/src/platform.rs
index d7d3b990..013f709d 100644
--- a/rust/src/platform.rs
+++ b/rust/src/platform.rs
@@ -82,7 +82,7 @@ impl Platform {
Ref::new(Self { handle })
}
- pub fn by_name<S: IntoCStr>(name: S) -> Option<Ref<Self>> {
+ pub fn by_name(name: &str) -> Option<Ref<Self>> {
let raw_name = name.to_cstr();
unsafe {
let res = BNGetPlatformByName(raw_name.as_ptr());
@@ -113,7 +113,7 @@ impl Platform {
}
}
- pub fn list_by_os<S: IntoCStr>(name: S) -> Array<Platform> {
+ pub fn list_by_os(name: &str) -> Array<Platform> {
let raw_name = name.to_cstr();
unsafe {
@@ -124,7 +124,7 @@ impl Platform {
}
}
- pub fn list_by_os_and_arch<S: IntoCStr>(name: S, arch: &CoreArchitecture) -> Array<Platform> {
+ pub fn list_by_os_and_arch(name: &str, arch: &CoreArchitecture) -> Array<Platform> {
let raw_name = name.to_cstr();
unsafe {
@@ -145,7 +145,7 @@ impl Platform {
}
}
- pub fn new<A: Architecture, S: IntoCStr>(arch: &A, name: S) -> Ref<Self> {
+ pub fn new<A: Architecture>(arch: &A, name: &str) -> Ref<Self> {
let name = name.to_cstr();
unsafe {
let handle = BNCreatePlatform(arch.as_ref().handle, name.as_ptr());
@@ -173,7 +173,7 @@ impl Platform {
unsafe { TypeContainer::from_raw(type_container_ptr.unwrap()) }
}
- pub fn get_type_libraries_by_name<T: IntoCStr>(&self, name: T) -> Array<TypeLibrary> {
+ pub fn get_type_libraries_by_name(&self, name: &str) -> Array<TypeLibrary> {
let mut count = 0;
let name = name.to_cstr();
let result =
@@ -182,9 +182,8 @@ impl Platform {
unsafe { Array::new(result, count, ()) }
}
- pub fn register_os<S: IntoCStr>(&self, os: S) {
+ pub fn register_os(&self, os: &str) {
let os = os.to_cstr();
-
unsafe {
BNRegisterPlatform(os.as_ptr(), self.handle);
}