diff options
| author | Mason Reed <mason@vector35.com> | 2025-05-05 13:17:30 -0400 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2025-05-12 17:45:24 -0400 |
| commit | 9dadf92c16da5cd21def79ae39ca98803c9208ec (patch) | |
| tree | 3874a659bcb3818f43c1a46ab3ef081b99b47154 /rust/src/binary_view.rs | |
| parent | 9f5491a56f6af1fa9b030f23d40150673a52aaa1 (diff) | |
[Rust] Rename `AsCStr` to `IntoCStr`
Diffstat (limited to 'rust/src/binary_view.rs')
| -rw-r--r-- | rust/src/binary_view.rs | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/rust/src/binary_view.rs b/rust/src/binary_view.rs index a0fb9081..7259efbf 100644 --- a/rust/src/binary_view.rs +++ b/rust/src/binary_view.rs @@ -266,7 +266,7 @@ pub trait BinaryViewExt: BinaryViewBase { unsafe { BNGetEndOffset(self.as_ref().handle) } } - fn add_analysis_option(&self, name: impl AsCStr) { + fn add_analysis_option(&self, name: impl IntoCStr) { let name = name.to_cstr(); unsafe { BNAddAnalysisOption(self.as_ref().handle, name.as_ptr()) } } @@ -399,7 +399,7 @@ pub trait BinaryViewExt: BinaryViewBase { } } - fn symbol_by_raw_name<S: AsCStr>(&self, raw_name: S) -> Option<Ref<Symbol>> { + fn symbol_by_raw_name<S: IntoCStr>(&self, raw_name: S) -> Option<Ref<Symbol>> { let raw_name = raw_name.to_cstr(); unsafe { @@ -424,7 +424,7 @@ pub trait BinaryViewExt: BinaryViewBase { } } - fn symbols_by_name<S: AsCStr>(&self, name: S) -> Array<Symbol> { + fn symbols_by_name<S: IntoCStr>(&self, name: S) -> Array<Symbol> { let raw_name = name.to_cstr(); unsafe { @@ -585,7 +585,7 @@ pub trait BinaryViewExt: BinaryViewBase { } } - fn define_auto_type<T: Into<QualifiedName>, S: AsCStr>( + fn define_auto_type<T: Into<QualifiedName>, S: IntoCStr>( &self, name: T, source: S, @@ -602,7 +602,7 @@ pub trait BinaryViewExt: BinaryViewBase { QualifiedName::from_owned_raw(name_handle) } - fn define_auto_type_with_id<T: Into<QualifiedName>, S: AsCStr>( + fn define_auto_type_with_id<T: Into<QualifiedName>, S: IntoCStr>( &self, name: T, id: S, @@ -712,7 +712,7 @@ pub trait BinaryViewExt: BinaryViewBase { } } - fn undefine_auto_type<S: AsCStr>(&self, id: S) { + fn undefine_auto_type<S: IntoCStr>(&self, id: S) { let id_str = id.to_cstr(); unsafe { BNUndefineAnalysisType(self.as_ref().handle, id_str.as_ref().as_ptr() as *const _); @@ -763,7 +763,7 @@ pub trait BinaryViewExt: BinaryViewBase { } } - fn type_by_id<S: AsCStr>(&self, id: S) -> Option<Ref<Type>> { + fn type_by_id<S: IntoCStr>(&self, id: S) -> Option<Ref<Type>> { let id_str = id.to_cstr(); unsafe { let type_handle = BNGetAnalysisTypeById(self.as_ref().handle, id_str.as_ptr()); @@ -774,7 +774,7 @@ pub trait BinaryViewExt: BinaryViewBase { } } - fn type_name_by_id<S: AsCStr>(&self, id: S) -> Option<QualifiedName> { + fn type_name_by_id<S: IntoCStr>(&self, id: S) -> Option<QualifiedName> { let id_str = id.to_cstr(); unsafe { let name_handle = BNGetAnalysisTypeNameById(self.as_ref().handle, id_str.as_ptr()); @@ -871,7 +871,7 @@ pub trait BinaryViewExt: BinaryViewBase { section.create(self.as_ref()); } - fn remove_auto_section<S: AsCStr>(&self, name: S) { + fn remove_auto_section<S: IntoCStr>(&self, name: S) { let raw_name = name.to_cstr(); let raw_name_ptr = raw_name.as_ptr(); unsafe { @@ -879,7 +879,7 @@ pub trait BinaryViewExt: BinaryViewBase { } } - fn remove_user_section<S: AsCStr>(&self, name: S) { + fn remove_user_section<S: IntoCStr>(&self, name: S) { let raw_name = name.to_cstr(); let raw_name_ptr = raw_name.as_ptr(); unsafe { @@ -887,7 +887,7 @@ pub trait BinaryViewExt: BinaryViewBase { } } - fn section_by_name<S: AsCStr>(&self, name: S) -> Option<Ref<Section>> { + fn section_by_name<S: IntoCStr>(&self, name: S) -> Option<Ref<Section>> { unsafe { let raw_name = name.to_cstr(); let name_ptr = raw_name.as_ptr(); @@ -1103,14 +1103,14 @@ pub trait BinaryViewExt: BinaryViewBase { unsafe { BNApplyDebugInfo(self.as_ref().handle, debug_info.handle) } } - fn show_graph_report<S: AsCStr>(&self, raw_name: S, graph: &FlowGraph) { + fn show_graph_report<S: IntoCStr>(&self, raw_name: S, graph: &FlowGraph) { let raw_name = raw_name.to_cstr(); unsafe { BNShowGraphReport(self.as_ref().handle, raw_name.as_ptr(), graph.handle); } } - fn load_settings<S: AsCStr>(&self, view_type_name: S) -> Result<Ref<Settings>> { + fn load_settings<S: IntoCStr>(&self, view_type_name: S) -> Result<Ref<Settings>> { let view_type_name = view_type_name.to_cstr(); let settings_handle = unsafe { BNBinaryViewGetLoadSettings(self.as_ref().handle, view_type_name.as_ptr()) }; @@ -1122,7 +1122,7 @@ pub trait BinaryViewExt: BinaryViewBase { } } - fn set_load_settings<S: AsCStr>(&self, view_type_name: S, settings: &Settings) { + fn set_load_settings<S: IntoCStr>(&self, view_type_name: S, settings: &Settings) { let view_type_name = view_type_name.to_cstr(); unsafe { @@ -1139,7 +1139,7 @@ pub trait BinaryViewExt: BinaryViewBase { /// # Arguments /// * `name` - the name for the tag /// * `icon` - the icon (recommended 1 emoji or 2 chars) for the tag - fn create_tag_type<N: AsCStr, I: AsCStr>(&self, name: N, icon: I) -> Ref<TagType> { + fn create_tag_type<N: IntoCStr, I: IntoCStr>(&self, name: N, icon: I) -> Ref<TagType> { let tag_type = TagType::create(self.as_ref(), name, icon); unsafe { BNAddTagType(self.as_ref().handle, tag_type.handle); @@ -1153,7 +1153,7 @@ pub trait BinaryViewExt: BinaryViewBase { } /// Get a tag type by its name. - fn tag_type_by_name<S: AsCStr>(&self, name: S) -> Option<Ref<TagType>> { + fn tag_type_by_name<S: IntoCStr>(&self, name: S) -> Option<Ref<TagType>> { let name = name.to_cstr(); unsafe { let handle = BNGetTagType(self.as_ref().handle, name.as_ptr()); @@ -1167,7 +1167,7 @@ pub trait BinaryViewExt: BinaryViewBase { /// Get a tag by its id. /// /// Note this does not tell you anything about where it is used. - fn tag_by_id<S: AsCStr>(&self, id: S) -> Option<Ref<Tag>> { + fn tag_by_id<S: IntoCStr>(&self, id: S) -> Option<Ref<Tag>> { let id = id.to_cstr(); unsafe { let handle = BNGetTag(self.as_ref().handle, id.as_ptr()); @@ -1181,7 +1181,7 @@ pub trait BinaryViewExt: BinaryViewBase { /// Creates and adds a tag to an address /// /// User tag creations will be added to the undo buffer - fn add_tag<S: AsCStr>(&self, addr: u64, t: &TagType, data: S, user: bool) { + fn add_tag<S: IntoCStr>(&self, addr: u64, t: &TagType, data: S, user: bool) { let tag = Tag::new(t, data); unsafe { BNAddTag(self.as_ref().handle, tag.handle, user) } @@ -1218,7 +1218,7 @@ pub trait BinaryViewExt: BinaryViewBase { /// /// NOTE: This is different from setting a comment at the function-level. To set a comment in a /// function use [`Function::set_comment_at`] - fn set_comment_at(&self, addr: u64, comment: impl AsCStr) { + fn set_comment_at(&self, addr: u64, comment: impl IntoCStr) { let comment_raw = comment.to_cstr(); unsafe { BNSetGlobalCommentForAddress(self.as_ref().handle, addr, comment_raw.as_ptr()) } } @@ -1271,7 +1271,7 @@ pub trait BinaryViewExt: BinaryViewBase { result } - fn query_metadata<S: AsCStr>(&self, key: S) -> Option<Ref<Metadata>> { + fn query_metadata<S: IntoCStr>(&self, key: S) -> Option<Ref<Metadata>> { let key = key.to_cstr(); let value: *mut BNMetadata = unsafe { BNBinaryViewQueryMetadata(self.as_ref().handle, key.as_ptr()) }; @@ -1282,7 +1282,7 @@ pub trait BinaryViewExt: BinaryViewBase { } } - fn get_metadata<T, S: AsCStr>(&self, key: S) -> Option<Result<T>> + fn get_metadata<T, S: IntoCStr>(&self, key: S) -> Option<Result<T>> where T: for<'a> TryFrom<&'a Metadata>, { @@ -1290,7 +1290,7 @@ pub trait BinaryViewExt: BinaryViewBase { .map(|md| T::try_from(md.as_ref()).map_err(|_| ())) } - fn store_metadata<V, S: AsCStr>(&self, key: S, value: V, is_auto: bool) + fn store_metadata<V, S: IntoCStr>(&self, key: S, value: V, is_auto: bool) where V: Into<Ref<Metadata>>, { @@ -1306,7 +1306,7 @@ pub trait BinaryViewExt: BinaryViewBase { }; } - fn remove_metadata<S: AsCStr>(&self, key: S) { + fn remove_metadata<S: IntoCStr>(&self, key: S) { let key = key.to_cstr(); unsafe { BNBinaryViewRemoveMetadata(self.as_ref().handle, key.as_ptr()) }; } @@ -1432,7 +1432,7 @@ pub trait BinaryViewExt: BinaryViewBase { .collect() } - fn component_by_guid<S: AsCStr>(&self, guid: S) -> Option<Ref<Component>> { + fn component_by_guid<S: IntoCStr>(&self, guid: S) -> Option<Ref<Component>> { let name = guid.to_cstr(); let result = unsafe { BNGetComponentByGuid(self.as_ref().handle, name.as_ptr()) }; NonNull::new(result).map(|h| unsafe { Component::ref_from_raw(h) }) @@ -1443,7 +1443,7 @@ pub trait BinaryViewExt: BinaryViewBase { NonNull::new(result).map(|h| unsafe { Component::ref_from_raw(h) }) } - fn component_by_path<P: AsCStr>(&self, path: P) -> Option<Ref<Component>> { + fn component_by_path<P: IntoCStr>(&self, path: P) -> Option<Ref<Component>> { let path = path.to_cstr(); let result = unsafe { BNGetComponentByPath(self.as_ref().handle, path.as_ptr()) }; NonNull::new(result).map(|h| unsafe { Component::ref_from_raw(h) }) @@ -1453,7 +1453,7 @@ pub trait BinaryViewExt: BinaryViewBase { unsafe { BNRemoveComponent(self.as_ref().handle, component.handle.as_ptr()) } } - fn remove_component_by_guid<P: AsCStr>(&self, guid: P) -> bool { + fn remove_component_by_guid<P: IntoCStr>(&self, guid: P) -> bool { let path = guid.to_cstr(); unsafe { BNRemoveComponentByGuid(self.as_ref().handle, path.as_ptr()) } } @@ -1476,7 +1476,7 @@ pub trait BinaryViewExt: BinaryViewBase { unsafe { Array::new(result, count, ()) } } - fn external_library<S: AsCStr>(&self, name: S) -> Option<Ref<ExternalLibrary>> { + fn external_library<S: IntoCStr>(&self, name: S) -> Option<Ref<ExternalLibrary>> { let name_ptr = name.to_cstr(); let result = unsafe { BNBinaryViewGetExternalLibrary(self.as_ref().handle, name_ptr.as_ptr()) }; @@ -1484,12 +1484,12 @@ pub trait BinaryViewExt: BinaryViewBase { Some(unsafe { ExternalLibrary::ref_from_raw(result_ptr) }) } - fn remove_external_library<S: AsCStr>(&self, name: S) { + fn remove_external_library<S: IntoCStr>(&self, name: S) { let name_ptr = name.to_cstr(); unsafe { BNBinaryViewRemoveExternalLibrary(self.as_ref().handle, name_ptr.as_ptr()) }; } - fn add_external_library<S: AsCStr>( + fn add_external_library<S: IntoCStr>( &self, name: S, backing_file: Option<&ProjectFile>, @@ -1531,7 +1531,7 @@ pub trait BinaryViewExt: BinaryViewBase { } // TODO: This is awful, rewrite this. - fn add_external_location<S: AsCStr>( + fn add_external_location<S: IntoCStr>( &self, symbol: &Symbol, library: &ExternalLibrary, @@ -1589,7 +1589,7 @@ pub trait BinaryViewExt: BinaryViewBase { unsafe { BNAddBinaryViewTypeLibrary(self.as_ref().handle, library.as_raw()) } } - fn type_library_by_name<S: AsCStr>(&self, name: S) -> Option<TypeLibrary> { + fn type_library_by_name<S: IntoCStr>(&self, name: S) -> Option<TypeLibrary> { let name = name.to_cstr(); let result = unsafe { BNGetBinaryViewTypeLibrary(self.as_ref().handle, name.as_ptr()) }; NonNull::new(result).map(|h| unsafe { TypeLibrary::from_raw(h) }) @@ -1682,7 +1682,7 @@ pub trait BinaryViewExt: BinaryViewBase { /// contain a metadata key called "type_guids" which is a map /// Dict[string_guid, string_type_name] or /// Dict[string_guid, Tuple[string_type_name, type_library_name]] - fn import_type_by_guid<S: AsCStr>(&self, guid: S) -> Option<Ref<Type>> { + fn import_type_by_guid<S: IntoCStr>(&self, guid: S) -> Option<Ref<Type>> { let guid = guid.to_cstr(); let result = unsafe { BNBinaryViewImportTypeLibraryTypeByGuid(self.as_ref().handle, guid.as_ptr()) }; |
