rust-pcap / pcap

Rust language pcap library
Apache License 2.0
598 stars 138 forks source link

Rename Capture::next to a name that does not suggest it is an iterator #225

Closed Wojtek242 closed 1 year ago

Wojtek242 commented 2 years ago

Capture::next suggests that Capture implements an iterator. It does not. Suggest renaming it to nextpacket which then mirrors sendpacket even though it breaks away from libpcap naming (which it already was not holding that well).

Stargateur commented 2 years ago

It's not a bad idea, Capture is more an interface to pcap API. Thus I think I will work to add an iterator.

next_packet and send_packet make more sense to me.

Wojtek242 commented 2 years ago

You think an iterator still makes sense? The issue I see with an iterator is that there is no underlying collection and unless copied the packets do not remain so calling next on libpcap does not really do the same thing as next on a list/vec/map.

Wojtek242 commented 2 years ago

You think an iterator still makes sense? The issue I see with an iterator is that there is no underlying collection and unless copied the packets do not remain so calling next on libpcap does not really do the same thing as next on a list/vec/map.

Actually stream iterators make sense. I don't know why I forgot about them.

Wojtek242 commented 1 year ago

Closed by https://github.com/rust-pcap/pcap/pull/229