Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust API could be more Rusty #3714

Closed
dyslexicsteak opened this issue Dec 3, 2022 · 1 comment
Closed

Rust API could be more Rusty #3714

dyslexicsteak opened this issue Dec 3, 2022 · 1 comment
Assignees
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

Comments

@dyslexicsteak
Copy link

dyslexicsteak commented Dec 3, 2022

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() then headless::shutdown(), the Rust type system is able to express this in a more concise and friendly manner: create a struct that represents a session, say HeadlessSession, and implement all initialisation within a new associated function (static method), then impl Drop for HeadlessSession and place shutdown behaviour in drop 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 a SessionConfig 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.

@dyslexicsteak dyslexicsteak added the Type: Enhancement Issue is a small enhancement to existing functionality label Dec 3, 2022
@ElykDeer ElykDeer added Effort: Medium Issue should take < 1 month Impact: Low Issue is a papercut or has a good, supported workaround Component: Rust API Issue needs changes to the Rust API good first issue labels Feb 8, 2023
@ElykDeer
Copy link
Member

ElykDeer commented Dec 5, 2023

There are still plenty of things in the API that could be "more Rusty," but I'll leave those for more specific issues. :)

Let me know if this doesn't work like you were thinking it would. Not right now sure what other config options we'd want to provide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

3 participants