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/repository/plugin.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/repository/plugin.rs')
| -rw-r--r-- | rust/src/repository/plugin.rs | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/rust/src/repository/plugin.rs b/rust/src/repository/plugin.rs index af3886f2..82309e79 100644 --- a/rust/src/repository/plugin.rs +++ b/rust/src/repository/plugin.rs @@ -31,31 +31,31 @@ impl RepositoryPlugin { } /// String of the plugin author - pub fn author(&self) -> BnString { + pub fn author(&self) -> String { let result = unsafe { BNPluginGetAuthor(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 short description of the plugin - pub fn description(&self) -> BnString { + pub fn description(&self) -> String { let result = unsafe { BNPluginGetDescription(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 complete license text for the given plugin - pub fn license_text(&self) -> BnString { + pub fn license_text(&self) -> String { let result = unsafe { BNPluginGetLicenseText(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 long description of the plugin - pub fn long_description(&self) -> BnString { + pub fn long_description(&self) -> String { let result = unsafe { BNPluginGetLongdescription(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) } } /// Minimum version info the plugin was tested on @@ -71,65 +71,65 @@ impl RepositoryPlugin { } /// String plugin name - pub fn name(&self) -> BnString { + pub fn name(&self) -> String { let result = unsafe { BNPluginGetName(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 URL of the plugin's git repository - pub fn project_url(&self) -> BnString { + pub fn project_url(&self) -> String { let result = unsafe { BNPluginGetProjectUrl(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 URL of the plugin's git repository - pub fn package_url(&self) -> BnString { + pub fn package_url(&self) -> String { let result = unsafe { BNPluginGetPackageUrl(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 URL of the plugin author's url - pub fn author_url(&self) -> BnString { + pub fn author_url(&self) -> String { let result = unsafe { BNPluginGetAuthorUrl(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 version of the plugin - pub fn version(&self) -> BnString { + pub fn version(&self) -> String { let result = unsafe { BNPluginGetVersion(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 of the commit of this plugin git repository - pub fn commit(&self) -> BnString { + pub fn commit(&self) -> String { let result = unsafe { BNPluginGetCommit(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) } } /// Relative path from the base of the repository to the actual plugin - pub fn path(&self) -> BnString { + pub fn path(&self) -> String { let result = unsafe { BNPluginGetPath(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) } } /// Optional sub-directory the plugin code lives in as a relative path from the plugin root - pub fn subdir(&self) -> BnString { + pub fn subdir(&self) -> String { let result = unsafe { BNPluginGetSubdir(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) } } /// Dependencies required for installing this plugin - pub fn dependencies(&self) -> BnString { + pub fn dependencies(&self) -> String { let result = unsafe { BNPluginGetDependencies(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) } } /// true if the plugin is installed, false otherwise @@ -190,10 +190,10 @@ impl RepositoryPlugin { unsafe { Array::new(result, count, ()) } } - pub fn repository(&self) -> BnString { + pub fn repository(&self) -> String { let result = unsafe { BNPluginGetRepository(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) } } /// Boolean status indicating that the plugin is being deleted @@ -237,10 +237,10 @@ impl RepositoryPlugin { } /// Gets a json object of the project data field - pub fn project_data(&self) -> BnString { + pub fn project_data(&self) -> String { let result = unsafe { BNPluginGetProjectData(self.handle.as_ptr()) }; assert!(!result.is_null()); - unsafe { BnString::from_raw(result) } + unsafe { BnString::into_string(result) } } /// Returns a datetime object representing the plugins last update |
