Skip to content

Commit

Permalink
Misc rust formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
emesare committed Jan 25, 2025
1 parent 0263957 commit 0feeaf5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion rust/src/collaboration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use crate::string::{BnStrCompatible, BnString};
// TODO: the data because they have a greater understanding of where the function is being called from.

/// Check whether the client has collaboration support.
///
///
/// Call this if you intend on providing divergent behavior, as otherwise you will likely
/// crash calling collaboration APIs on unsupported builds of Binary Ninja.
pub fn has_collaboration_support() -> bool {
Expand Down
19 changes: 14 additions & 5 deletions rust/src/headless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ use thiserror::Error;

use crate::enterprise::release_license;
use crate::main_thread::{MainThreadAction, MainThreadHandler};
use crate::progress::ProgressCallback;
use crate::rc::Ref;
use binaryninjacore_sys::{BNInitPlugins, BNInitRepoPlugins};
use std::sync::mpsc::Sender;
use std::sync::Mutex;
use std::thread::JoinHandle;
use std::time::Duration;
use crate::progress::ProgressCallback;

static MAIN_THREAD_HANDLE: Mutex<Option<JoinHandle<()>>> = Mutex::new(None);

Expand Down Expand Up @@ -293,12 +293,16 @@ impl Session {
/// println!("{}/{}", progress, total);
/// true
/// };
///
///
/// let bv = headless_session
/// .load_with_progress("cat.bndb", print_progress)
/// .expect("Couldn't open `cat.bndb`");
/// ```
pub fn load_with_progress(&self, file_path: impl AsRef<Path>, progress: impl ProgressCallback) -> Option<Ref<binary_view::BinaryView>> {
pub fn load_with_progress(
&self,
file_path: impl AsRef<Path>,
progress: impl ProgressCallback,
) -> Option<Ref<binary_view::BinaryView>> {
crate::load_with_progress(file_path, progress)
}

Expand Down Expand Up @@ -333,7 +337,7 @@ impl Session {
/// println!("{}/{}", progress, total);
/// true
/// };
///
///
/// let settings: Ref<Metadata> =
/// HashMap::from([("analysis.linearSweep.autorun", false.into())]).into();
/// let headless_session = binaryninja::headless::Session::new().unwrap();
Expand All @@ -349,7 +353,12 @@ impl Session {
options: Option<O>,
progress: impl ProgressCallback,
) -> Option<Ref<binary_view::BinaryView>> {
crate::load_with_options_and_progress(file_path, update_analysis_and_wait, options, progress)
crate::load_with_options_and_progress(
file_path,
update_analysis_and_wait,
options,
progress,
)
}
}

Expand Down
2 changes: 1 addition & 1 deletion rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub fn load(file_path: impl AsRef<Path>) -> Option<Ref<BinaryView>> {
}

/// Equivalent to [`load`] but with a progress callback.
///
///
/// NOTE: The progress callback will _only_ be called when loading BNDBs.
pub fn load_with_progress<P: ProgressCallback>(
file_path: impl AsRef<Path>,
Expand Down
4 changes: 3 additions & 1 deletion rust/tests/collaboration.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use binaryninja::binary_view::BinaryViewExt;
use binaryninja::collaboration::{has_collaboration_support, NoNameChangeset, Remote, RemoteFileType, RemoteProject};
use binaryninja::collaboration::{
has_collaboration_support, NoNameChangeset, Remote, RemoteFileType, RemoteProject,
};
use binaryninja::headless::Session;
use binaryninja::symbol::{SymbolBuilder, SymbolType};
use rstest::*;
Expand Down

0 comments on commit 0feeaf5

Please sign in to comment.