diff options
| author | Mason Reed <mason@vector35.com> | 2025-05-03 23:15:17 -0400 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2025-05-12 17:45:24 -0400 |
| commit | 6264254065bbae9d89f51cf3330379b7ace09592 (patch) | |
| tree | 9ece1d1739215c2faef2d808ef4fdc019ad527fa /rust/src/settings.rs | |
| parent | c3fdda9727f5507818e3f55576ad32215a22b0f9 (diff) | |
[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.
Diffstat (limited to 'rust/src/settings.rs')
| -rw-r--r-- | rust/src/settings.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/rust/src/settings.rs b/rust/src/settings.rs index 8c64f314..4b4d418f 100644 --- a/rust/src/settings.rs +++ b/rust/src/settings.rs @@ -58,8 +58,8 @@ impl Settings { unsafe { BNSettingsSetResourceId(self.handle, resource_id.as_ref().as_ptr() as *mut _) }; } - pub fn serialize_schema(&self) -> BnString { - unsafe { BnString::from_raw(BNSettingsSerializeSchema(self.handle)) } + pub fn serialize_schema(&self) -> String { + unsafe { BnString::into_string(BNSettingsSerializeSchema(self.handle)) } } pub fn deserialize_schema<S: BnStrCompatible>(&self, schema: S) -> bool { @@ -184,7 +184,7 @@ impl Settings { } } - pub fn get_string<S: BnStrCompatible>(&self, key: S) -> BnString { + pub fn get_string<S: BnStrCompatible>(&self, key: S) -> String { self.get_string_with_opts(key, &mut QueryOptions::default()) } @@ -192,7 +192,7 @@ impl Settings { &self, key: S, options: &mut QueryOptions, - ) -> BnString { + ) -> String { let key = key.into_bytes_with_nul(); let view_ptr = match options.view.as_ref() { Some(view) => view.handle, @@ -203,7 +203,7 @@ impl Settings { _ => std::ptr::null_mut(), }; unsafe { - BnString::from_raw(BNSettingsGetString( + BnString::into_string(BNSettingsGetString( self.handle, key.as_ref().as_ptr() as *mut _, view_ptr, @@ -248,7 +248,7 @@ impl Settings { } } - pub fn get_json<S: BnStrCompatible>(&self, key: S) -> BnString { + pub fn get_json<S: BnStrCompatible>(&self, key: S) -> String { self.get_json_with_opts(key, &mut QueryOptions::default()) } @@ -256,7 +256,7 @@ impl Settings { &self, key: S, options: &mut QueryOptions, - ) -> BnString { + ) -> String { let key = key.into_bytes_with_nul(); let view_ptr = match options.view.as_ref() { Some(view) => view.handle, @@ -267,7 +267,7 @@ impl Settings { _ => std::ptr::null_mut(), }; unsafe { - BnString::from_raw(BNSettingsGetJson( + BnString::into_string(BNSettingsGetJson( self.handle, key.as_ref().as_ptr() as *mut _, view_ptr, @@ -479,11 +479,11 @@ impl Settings { } } - pub fn get_property_string<S: BnStrCompatible>(&self, key: S, property: S) -> BnString { + pub fn get_property_string<S: BnStrCompatible>(&self, key: S, property: S) -> String { let key = key.into_bytes_with_nul(); let property = property.into_bytes_with_nul(); unsafe { - BnString::from_raw(BNSettingsQueryPropertyString( + BnString::into_string(BNSettingsQueryPropertyString( self.handle, key.as_ref().as_ptr() as *mut _, property.as_ref().as_ptr() as *mut _, |
