Skip to content

Commit 8bf4ab5

Browse files
committed
[Rust] Impl Debug for DownloadProvider
1 parent 18d7e47 commit 8bf4ab5

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

rust/src/download/provider.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use crate::download::{CustomDownloadInstance, DownloadInstance};
22
use crate::rc::{Array, CoreArrayProvider, CoreArrayProviderInner, Guard, Ref};
33
use crate::settings::Settings;
4-
use crate::string::IntoCStr;
4+
use crate::string::{BnString, IntoCStr};
55
use binaryninjacore_sys::*;
66
use std::ffi::c_void;
7+
use std::fmt::Debug;
78
use std::mem::MaybeUninit;
89

910
/// 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 {
8182
Self::get(&dp_name).ok_or(())
8283
}
8384

85+
pub fn name(&self) -> String {
86+
unsafe { BnString::into_string(BNGetDownloadProviderName(self.handle)) }
87+
}
88+
8489
pub fn create_instance(&self) -> Result<Ref<DownloadInstance>, ()> {
8590
let result: *mut BNDownloadInstance =
8691
unsafe { BNCreateDownloadProviderInstance(self.handle) };
@@ -92,6 +97,14 @@ impl DownloadProvider {
9297
}
9398
}
9499

100+
impl Debug for DownloadProvider {
101+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
102+
f.debug_struct("DownloadProvider")
103+
.field("name", &self.name())
104+
.finish()
105+
}
106+
}
107+
95108
impl CoreArrayProvider for DownloadProvider {
96109
type Raw = *mut BNDownloadProvider;
97110
type Context = ();

0 commit comments

Comments
 (0)