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

Allow using capture asynchronously, without having to create an allocating StreamCodec. #322

Open
Frostie314159 opened this issue Jan 10, 2024 · 4 comments

Comments

@Frostie314159
Copy link

It would be nice, to be able to use a capture asynchronously, without the Codec forcing you to allocate.

@Wojtek242
Copy link
Collaborator

Could you please give a code sample that you would like to see working with pcap? That way it will be easier to target exactly the feature you would like.

@Frostie314159
Copy link
Author

In my case, I was relying on the fact, that pcap internally just keeps an fd and using tokio, you can do async read and write operations on that. Providing an API similar to that would be great to have. I just have a fixed length array, into which I read the data, process it and then continue to the next packet.

let mut buf = [0x00; 1500];
let len = capture.read(&mut buf).await.unwrap();

@Stargateur
Copy link
Contributor

@Frostie314159
Copy link
Author

There is no codec used in that example and it is sync not async.

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

No branches or pull requests

3 participants