Equivalent to [`load_view`] but with a progress callback.
(
bv: &BinaryView,
update_analysis_and_wait: bool,
options: Option<O>,
mut progress: P,
)
| 237 | |
| 238 | /// Equivalent to [`load_view`] but with a progress callback. |
| 239 | pub fn load_view_with_progress<O, P>( |
| 240 | bv: &BinaryView, |
| 241 | update_analysis_and_wait: bool, |
| 242 | options: Option<O>, |
| 243 | mut progress: P, |
| 244 | ) -> Option<Ref<BinaryView>> |
| 245 | where |
| 246 | O: IntoJson, |
| 247 | P: ProgressCallback, |
| 248 | { |
| 249 | let options_or_default = if let Some(opt) = options { |
| 250 | opt.get_json_string() |
| 251 | .ok()? |
| 252 | .into_bytes_with_nul() |
| 253 | .as_ref() |
| 254 | .to_vec() |
| 255 | } else { |
| 256 | Metadata::new_of_type(MetadataType::KeyValueDataType) |
| 257 | .get_json_string() |
| 258 | .ok()? |
| 259 | .as_ref() |
| 260 | .to_vec() |
| 261 | }; |
| 262 | let handle = unsafe { |
| 263 | BNLoadBinaryView( |
| 264 | bv.handle as *mut _, |
| 265 | update_analysis_and_wait, |
| 266 | options_or_default.as_ptr() as *mut c_char, |
| 267 | Some(P::cb_progress_callback), |
| 268 | &mut progress as *mut P as *mut c_void, |
| 269 | ) |
| 270 | }; |
| 271 | |
| 272 | if handle.is_null() { |
| 273 | None |
| 274 | } else { |
| 275 | Some(unsafe { BinaryView::ref_from_raw(handle) }) |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | pub fn install_directory() -> PathBuf { |
| 280 | let install_dir_ptr: *mut c_char = unsafe { BNGetInstallDirectory() }; |
no test coverage detected