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

Add callback API into Rules #33

Merged
merged 5 commits into from Jul 22, 2021
Merged

Conversation

ikrivosheev
Copy link
Contributor

Hello @Hugal31 , sorry for my english, I will try to describe what I want to do.

  1. I kept the old api for backward compatibility
  2. Callback api provides more control over scanning
  3. I am writing an engine that will be integrated with python. To avoid converting from a Vec to PyList, I want to immediately add Rule to PyList

If this PR is Ok, I can write Callback API for Scanner

Copy link
Owner

@Hugal31 Hugal31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR, it looks great! I left a few comments for things I'd like to change.
Could you also add a few unit tests please?

src/rules.rs Outdated Show resolved Hide resolved
src/internals/scan.rs Outdated Show resolved Hide resolved
src/internals/scan.rs Show resolved Hide resolved
@ikrivosheev ikrivosheev requested a review from Hugal31 July 20, 2021 13:18
@ikrivosheev
Copy link
Contributor Author

ikrivosheev commented Jul 20, 2021

Thanks for your PR, it looks great! I left a few comments for things I'd like to change.
Could you also add a few unit tests please?

Thank you for review!

  1. Fix memory leak
  2. Add more tests for callback

I have a question: Scanner callback API make similar Rule callback API or set callback into Scanner, like this:

let rules = Rules...;
let scanner = rules.scanner();
scanner.set_callback(...);
scanner.set_timeout(...);

?

@ikrivosheev ikrivosheev force-pushed the callback_api branch 2 times, most recently from ca559d7 to 360183a Compare July 20, 2021 16:23
@Hugal31
Copy link
Owner

Hugal31 commented Jul 21, 2021

I have a question: Scanner callback API make similar Rule callback API or set callback into Scanner, like this:

let rules = Rules...;
let scanner = rules.scanner();
scanner.set_callback(...);
scanner.set_timeout(...);

?

I'm not sure. I think I prefer to keep it as the Rule API, it might be more convenient to use closures.

src/internals/scan.rs Outdated Show resolved Hide resolved
@ikrivosheev
Copy link
Contributor Author

@Hugal31, I add Scanner callback API

@ikrivosheev
Copy link
Contributor Author

ikrivosheev commented Jul 22, 2021

@Hugal31 rebase master.

Can you make release? I need this changes in project

@Hugal31 Hugal31 merged commit 562ec2c into Hugal31:master Jul 22, 2021
@ikrivosheev ikrivosheev deleted the callback_api branch July 22, 2021 12:31
@Hugal31
Copy link
Owner

Hugal31 commented Jul 22, 2021

v0.8.0 released!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants