ProgressCallback in binaryninja::progress - Rust

Trait ProgressCallback

Source

pub trait ProgressCallback: Sized {
    type SplitProgressType: SplitProgressBuilder;

    // Required methods
    fn progress(&mut self, progress: usize, total: usize) -> bool;
    fn split(self, subpart_weights: &'static [usize]) -> Self::SplitProgressType;

    // Provided methods
    unsafe extern "C" fn cb_progress_callback(
        ctxt: *mut c_void,
        progress: usize,
        total: usize,
    ) -> bool { ... }
    unsafe fn into_raw(&mut self) -> *mut c_void { ... }
}

Source

Source

Caller function will call this to report progress.

Return false to tell the caller to stop.

Source

Split a single progress function into proportionally sized subparts. This function takes the original progress function and returns a new function whose signature is the same but whose output is shortened to correspond to the specified subparts.

The length of a subpart is proportional to the sum of all the weights. E.g. with subpart_weights = &[ 25, 50, 25 ], this will return a function that calls progress_func and maps its progress to the ranges [0..=25, 25..=75, 75..=100]

Weights of subparts, described above

  • progress_func - Original progress function (usually updates a UI)
  • subpart_weights - Weights of subparts, described above

Source
Source

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.