From 6264254065bbae9d89f51cf3330379b7ace09592 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Sat, 3 May 2025 23:15:17 -0400 Subject: [Rust] Return `String` instead of `BnString` for cases where lossy conversion can be tolerated Still need to go and audit all usage, but realistically the most important places to give the user control are with symbols, where the data can come from non utf8 sources This is still incomplete, I just looked for usage of -> BnString so any other variant was omitted. --- rust/src/enterprise.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'rust/src/enterprise.rs') diff --git a/rust/src/enterprise.rs b/rust/src/enterprise.rs index 7030b194..9b97a387 100644 --- a/rust/src/enterprise.rs +++ b/rust/src/enterprise.rs @@ -98,13 +98,13 @@ pub fn release_license() { } // TODO: If "" string return None -pub fn server_username() -> BnString { - unsafe { BnString::from_raw(binaryninjacore_sys::BNGetEnterpriseServerUsername()) } +pub fn server_username() -> String { + unsafe { BnString::into_string(binaryninjacore_sys::BNGetEnterpriseServerUsername()) } } // TODO: If "" string return None -pub fn server_url() -> BnString { - unsafe { BnString::from_raw(binaryninjacore_sys::BNGetEnterpriseServerUrl()) } +pub fn server_url() -> String { + unsafe { BnString::into_string(binaryninjacore_sys::BNGetEnterpriseServerUrl()) } } pub fn set_server_url(url: S) -> Result<(), ()> { @@ -121,24 +121,24 @@ pub fn set_server_url(url: S) -> Result<(), ()> { } } -pub fn server_name() -> BnString { - unsafe { BnString::from_raw(binaryninjacore_sys::BNGetEnterpriseServerName()) } +pub fn server_name() -> String { + unsafe { BnString::into_string(binaryninjacore_sys::BNGetEnterpriseServerName()) } } -pub fn server_id() -> BnString { - unsafe { BnString::from_raw(binaryninjacore_sys::BNGetEnterpriseServerId()) } +pub fn server_id() -> String { + unsafe { BnString::into_string(binaryninjacore_sys::BNGetEnterpriseServerId()) } } pub fn server_version() -> u64 { unsafe { binaryninjacore_sys::BNGetEnterpriseServerVersion() } } -pub fn server_build_id() -> BnString { - unsafe { BnString::from_raw(binaryninjacore_sys::BNGetEnterpriseServerBuildId()) } +pub fn server_build_id() -> String { + unsafe { BnString::into_string(binaryninjacore_sys::BNGetEnterpriseServerBuildId()) } } -pub fn server_token() -> BnString { - unsafe { BnString::from_raw(binaryninjacore_sys::BNGetEnterpriseServerToken()) } +pub fn server_token() -> String { + unsafe { BnString::into_string(binaryninjacore_sys::BNGetEnterpriseServerToken()) } } pub fn license_duration() -> Duration { @@ -226,8 +226,8 @@ pub fn initialize_server() -> bool { unsafe { binaryninjacore_sys::BNInitializeEnterpriseServer() } } -pub fn server_last_error() -> BnString { - unsafe { BnString::from_raw(binaryninjacore_sys::BNGetEnterpriseServerLastError()) } +pub fn server_last_error() -> String { + unsafe { BnString::into_string(binaryninjacore_sys::BNGetEnterpriseServerLastError()) } } pub fn server_authentication_methods() -> (Array, Array) { -- cgit v1.3.1