summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-10-18 20:15:30 -0400
committerMason Reed <mason@vector35.com>2025-10-22 00:36:25 -0400
commit92656ce40229cd9962febe57678d7ae5378b31a0 (patch)
treefa109499c1336bab18105616c8d3935f27945c5c
parentee6add756b1149ee1a85a7c2f47301f4970b4332 (diff)
[Rust] Impl `Debug` for `DownloadProvider`
-rw-r--r--rust/src/download/provider.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/rust/src/download/provider.rs b/rust/src/download/provider.rs
index 795c4a7c..ec1baf93 100644
--- a/rust/src/download/provider.rs
+++ b/rust/src/download/provider.rs
@@ -1,9 +1,10 @@
use crate::download::{CustomDownloadInstance, DownloadInstance};
use crate::rc::{Array, CoreArrayProvider, CoreArrayProviderInner, Guard, Ref};
use crate::settings::Settings;
-use crate::string::IntoCStr;
+use crate::string::{BnString, IntoCStr};
use binaryninjacore_sys::*;
use std::ffi::c_void;
+use std::fmt::Debug;
use std::mem::MaybeUninit;
/// Register a new download provider type, which is used by the core (and other plugins) to make HTTP requests.
@@ -81,6 +82,10 @@ impl DownloadProvider {
Self::get(&dp_name).ok_or(())
}
+ pub fn name(&self) -> String {
+ unsafe { BnString::into_string(BNGetDownloadProviderName(self.handle)) }
+ }
+
pub fn create_instance(&self) -> Result<Ref<DownloadInstance>, ()> {
let result: *mut BNDownloadInstance =
unsafe { BNCreateDownloadProviderInstance(self.handle) };
@@ -92,6 +97,14 @@ impl DownloadProvider {
}
}
+impl Debug for DownloadProvider {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ f.debug_struct("DownloadProvider")
+ .field("name", &self.name())
+ .finish()
+ }
+}
+
impl CoreArrayProvider for DownloadProvider {
type Raw = *mut BNDownloadProvider;
type Context = ();