Rust API could be more Rusty #3714
Labels
Component: Rust API
Issue needs changes to the Rust API
Effort: Medium
Issue should take < 1 month
Impact: Low
Issue is a papercut or has a good, supported workaround
Type: Enhancement
Issue is a small enhancement to existing functionality
The Rust API is not as friendly or rusty as it could potentially be, one thing that stuck out to me as a large contributor to this is the need to call
headless::init()
thenheadless::shutdown()
, the Rust type system is able to express this in a more concise and friendly manner: create a struct that represents a session, sayHeadlessSession
, and implement all initialisation within anew
associated function (static method), thenimpl Drop for HeadlessSession
and place shutdown behaviour indrop
there. In this way, the lifetime of the session determines its validity in a way that the user is not required to remember anything, the user can drop it if they need to manually end a session or simply allow it to go out of scope normally.Any configuration options can be placed as arguments to
new
with aSessionConfig
struct, and any state that needs to be communicated can be placed behind getters on this struct, in this way, manipulations of the Binary Ninja instance can be consolidated into this struct, and the receiving of state information can be too.The text was updated successfully, but these errors were encountered: