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/lib.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'rust/src/lib.rs') diff --git a/rust/src/lib.rs b/rust/src/lib.rs index a3df0cd3..0446fe60 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -433,8 +433,8 @@ pub trait ObjectDestructor: 'static + Sync + Sized { } } -pub fn version() -> BnString { - unsafe { BnString::from_raw(BNGetVersionString()) } +pub fn version() -> String { + unsafe { BnString::into_string(BNGetVersionString()) } } pub fn build_id() -> u32 { @@ -512,16 +512,16 @@ pub fn version_info() -> VersionInfo { VersionInfo::from_owned_raw(info_raw) } -pub fn serial_number() -> BnString { - unsafe { BnString::from_raw(BNGetSerialNumber()) } +pub fn serial_number() -> String { + unsafe { BnString::into_string(BNGetSerialNumber()) } } pub fn is_license_validated() -> bool { unsafe { BNIsLicenseValidated() } } -pub fn licensed_user_email() -> BnString { - unsafe { BnString::from_raw(BNGetLicensedUserEmail()) } +pub fn licensed_user_email() -> String { + unsafe { BnString::into_string(BNGetLicensedUserEmail()) } } pub fn license_path() -> PathBuf { @@ -547,12 +547,12 @@ pub fn set_license(license: Option) { #[cfg(feature = "demo")] pub fn set_license(_license: Option) {} -pub fn product() -> BnString { - unsafe { BnString::from_raw(BNGetProduct()) } +pub fn product() -> String { + unsafe { BnString::into_string(BNGetProduct()) } } -pub fn product_type() -> BnString { - unsafe { BnString::from_raw(BNGetProductType()) } +pub fn product_type() -> String { + unsafe { BnString::into_string(BNGetProductType()) } } pub fn license_expiration_time() -> std::time::SystemTime { -- cgit v1.3.1