summaryrefslogtreecommitdiff
path: root/rust/src/database
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-05-03 23:15:17 -0400
committerMason Reed <35282038+emesare@users.noreply.github.com>2025-05-12 17:45:24 -0400
commit6264254065bbae9d89f51cf3330379b7ace09592 (patch)
tree9ece1d1739215c2faef2d808ef4fdc019ad527fa /rust/src/database
parentc3fdda9727f5507818e3f55576ad32215a22b0f9 (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/database')
-rw-r--r--rust/src/database/snapshot.rs4
-rw-r--r--rust/src/database/undo.rs8
2 files changed, 6 insertions, 6 deletions
diff --git a/rust/src/database/snapshot.rs b/rust/src/database/snapshot.rs
index 35b0dc46..3768138c 100644
--- a/rust/src/database/snapshot.rs
+++ b/rust/src/database/snapshot.rs
@@ -45,8 +45,8 @@ impl Snapshot {
}
/// Get the displayed snapshot name
- pub fn name(&self) -> BnString {
- unsafe { BnString::from_raw(BNGetSnapshotName(self.handle.as_ptr())) }
+ pub fn name(&self) -> String {
+ unsafe { BnString::into_string(BNGetSnapshotName(self.handle.as_ptr())) }
}
/// Set the displayed snapshot name
diff --git a/rust/src/database/undo.rs b/rust/src/database/undo.rs
index 727a777b..a2001b72 100644
--- a/rust/src/database/undo.rs
+++ b/rust/src/database/undo.rs
@@ -26,10 +26,10 @@ impl UndoEntry {
Ref::new(Self { handle })
}
- pub fn id(&self) -> BnString {
+ pub fn id(&self) -> String {
let result = unsafe { BNUndoEntryGetId(self.handle.as_ptr()) };
assert!(!result.is_null());
- unsafe { BnString::from_raw(result) }
+ unsafe { BnString::into_string(result) }
}
pub fn actions(&self) -> Array<UndoAction> {
@@ -115,10 +115,10 @@ impl UndoAction {
}
/// Gets the [`UndoAction`] summary as text rather than [`InstructionTextToken`]'s.
- pub fn summary_as_string(&self) -> BnString {
+ pub fn summary_as_string(&self) -> String {
let result = unsafe { BNUndoActionGetSummaryText(self.handle.as_ptr()) };
assert!(!result.is_null());
- unsafe { BnString::from_raw(result) }
+ unsafe { BnString::into_string(result) }
}
}