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/repository.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'rust/src/repository.rs') diff --git a/rust/src/repository.rs b/rust/src/repository.rs index 135b2367..90e414d5 100644 --- a/rust/src/repository.rs +++ b/rust/src/repository.rs @@ -31,17 +31,17 @@ impl Repository { } /// String URL of the git repository where the plugin repository's are stored - pub fn url(&self) -> BnString { + pub fn url(&self) -> String { let result = unsafe { BNRepositoryGetUrl(self.handle.as_ptr()) }; assert!(!result.is_null()); - unsafe { BnString::from_raw(result as *mut c_char) } + unsafe { BnString::into_string(result as *mut c_char) } } /// String local path to store the given plugin repository - pub fn path(&self) -> BnString { + pub fn path(&self) -> String { let result = unsafe { BNRepositoryGetRepoPath(self.handle.as_ptr()) }; assert!(!result.is_null()); - unsafe { BnString::from_raw(result as *mut c_char) } + unsafe { BnString::into_string(result as *mut c_char) } } /// List of RepoPlugin objects contained within this repository @@ -65,10 +65,10 @@ impl Repository { // TODO: Make this a PathBuf? /// String full path the repository - pub fn full_path(&self) -> BnString { + pub fn full_path(&self) -> String { let result = unsafe { BNRepositoryGetPluginsPath(self.handle.as_ptr()) }; assert!(!result.is_null()); - unsafe { BnString::from_raw(result as *mut c_char) } + unsafe { BnString::into_string(result as *mut c_char) } } } -- cgit v1.3.1