diff options
| author | Mason Reed <mason@vector35.com> | 2025-05-04 19:10:56 -0400 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2025-05-12 17:45:24 -0400 |
| commit | a826c589dfc10c542deba7ca3343a462e02d6bde (patch) | |
| tree | f116254bef39f787268bbecc5eac19da310db9ce /rust/src/collaboration/merge.rs | |
| parent | 28b3c4044af06fdc32c9c85bf8381b5058306427 (diff) | |
[Rust] Simplify `BnStrCompatible` trait
Followup to https://github.com/Vector35/binaryninja-api/pull/5897/
This simplifies usage of the trait in user code, should just be able to `to_cstr` to get the cstr repr and then call `as_ptr`.
Co-authored-by: Michael Krasnitski <michael.krasnitski@gmail.com>
Diffstat (limited to 'rust/src/collaboration/merge.rs')
| -rw-r--r-- | rust/src/collaboration/merge.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/rust/src/collaboration/merge.rs b/rust/src/collaboration/merge.rs index 68bfdc02..84aa6192 100644 --- a/rust/src/collaboration/merge.rs +++ b/rust/src/collaboration/merge.rs @@ -5,7 +5,7 @@ use std::ptr::NonNull; use crate::database::{snapshot::Snapshot, Database}; use crate::file_metadata::FileMetadata; use crate::rc::{CoreArrayProvider, CoreArrayProviderInner, Guard, Ref, RefCountable}; -use crate::string::{BnStrCompatible, BnString}; +use crate::string::{AsCStr, BnString}; pub type MergeConflictDataType = BNMergeConflictDataType; @@ -49,8 +49,8 @@ impl MergeConflict { NonNull::new(result).map(|handle| unsafe { Snapshot::from_raw(handle) }) } - pub fn path_item_string<S: BnStrCompatible>(&self, path: S) -> Result<BnString, ()> { - let path = path.into_bytes_with_nul(); + pub fn path_item_string<S: AsCStr>(&self, path: S) -> Result<BnString, ()> { + let path = path.to_cstr(); let result = unsafe { BNAnalysisMergeConflictGetPathItemString( self.handle.as_ptr(), @@ -123,8 +123,8 @@ impl MergeConflict { } /// Call this when you've resolved the conflict to save the result - pub fn success<S: BnStrCompatible>(&self, value: S) -> Result<(), ()> { - let value = value.into_bytes_with_nul(); + pub fn success<S: AsCStr>(&self, value: S) -> Result<(), ()> { + let value = value.to_cstr(); let success = unsafe { BNAnalysisMergeConflictSuccess( self.handle.as_ptr(), @@ -135,8 +135,8 @@ 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: BnStrCompatible>(&self, path_key: S) -> Option<u64> { - let path_key = path_key.into_bytes_with_nul(); + pub unsafe fn get_path_item_number<S: AsCStr>(&self, path_key: S) -> Option<u64> { + let path_key = path_key.to_cstr(); let value = unsafe { BNAnalysisMergeConflictGetPathItem( self.handle.as_ptr(), @@ -150,8 +150,8 @@ impl MergeConflict { } } - pub unsafe fn get_path_item_string<S: BnStrCompatible>(&self, path_key: S) -> Option<BnString> { - let path_key = path_key.into_bytes_with_nul(); + pub unsafe fn get_path_item_string<S: AsCStr>(&self, path_key: S) -> Option<BnString> { + let path_key = path_key.to_cstr(); let value = unsafe { BNAnalysisMergeConflictGetPathItemString( self.handle.as_ptr(), |
