summaryrefslogtreecommitdiff
path: root/rust/src/collaboration/merge.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/collaboration/merge.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/collaboration/merge.rs')
-rw-r--r--rust/src/collaboration/merge.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/rust/src/collaboration/merge.rs b/rust/src/collaboration/merge.rs
index 9ebf4cda..aea11701 100644
--- a/rust/src/collaboration/merge.rs
+++ b/rust/src/collaboration/merge.rs
@@ -48,7 +48,7 @@ impl MergeConflict {
NonNull::new(result).map(|handle| unsafe { Snapshot::from_raw(handle) })
}
- pub fn path_item_string<S: IntoCStr>(&self, path: S) -> Result<BnString, ()> {
+ pub fn path_item_string(&self, path: &str) -> Result<BnString, ()> {
let path = path.to_cstr();
let result = unsafe {
BNAnalysisMergeConflictGetPathItemString(self.handle.as_ptr(), path.as_ptr())
@@ -119,7 +119,7 @@ impl MergeConflict {
}
/// Call this when you've resolved the conflict to save the result
- pub fn success<S: IntoCStr>(&self, value: S) -> Result<(), ()> {
+ pub fn success(&self, value: &str) -> Result<(), ()> {
let value = value.to_cstr();
let success =
unsafe { BNAnalysisMergeConflictSuccess(self.handle.as_ptr(), value.as_ptr()) };
@@ -127,7 +127,7 @@ impl MergeConflict {
}
// TODO: Make a safe version of this that checks the path and if it holds a number
- pub unsafe fn get_path_item_number<S: IntoCStr>(&self, path_key: S) -> Option<u64> {
+ pub unsafe fn get_path_item_number(&self, path_key: &str) -> Option<u64> {
let path_key = path_key.to_cstr();
let value =
unsafe { BNAnalysisMergeConflictGetPathItem(self.handle.as_ptr(), path_key.as_ptr()) };
@@ -138,7 +138,7 @@ impl MergeConflict {
}
}
- pub unsafe fn get_path_item_string<S: IntoCStr>(&self, path_key: S) -> Option<BnString> {
+ pub unsafe fn get_path_item_string(&self, path_key: &str) -> Option<BnString> {
let path_key = path_key.to_cstr();
let value = unsafe {
BNAnalysisMergeConflictGetPathItemString(self.handle.as_ptr(), path_key.as_ptr())