-
Notifications
You must be signed in to change notification settings - Fork 473
tracer: update public API for smoltcp::phy::Tracer to allow custom inspection and printing of packet #1076
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1076 +/- ##
==========================================
+ Coverage 79.62% 80.29% +0.67%
==========================================
Files 81 81
Lines 24218 24303 +85
==========================================
+ Hits 19284 19515 +231
+ Misses 4934 4788 -146 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
src/phy/tracer.rs
Outdated
buffer: &'a [u8], | ||
medium: Medium, | ||
prefix: &'static str, | ||
direction: TracerDirection, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all of these can be pub
fields. Also, the struct as a whole should have #[derive(Debug, Clone)]
at least (probably Copy
too)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated interface of TracerPkt
to expose all fields publicly, removed now redundant constructor and accessor fields. Added Debug/Clone/Copy
auto-derives.
It looks like there's no tests, can you add some? |
566cf6d
to
8d1a9ad
Compare
…spection and printing of packet Currently `smoltcp::phy::tracer::Packet` is not exported as public type, which leaves very limited options for using `Tracer` device: traced packets only can be directly printed "as-is" and only in limited context (inside the closure). I'm updating API of `Tracer` device to provide access to internal fields of traced packet; this will enable implementation of custom printing or packet inspection functions I renamed `smoltcp::phy::tracer::Packet` to `smoltcp::phy::tracer::TracerPacket`, following prefixing convention used by types declared in `smoltcp::phy::pcap_writer`
Thank you for taking a look Catherine, Added unit test for the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Currently
smoltcp::phy::tracer::Packet
is not exported as public type, which leaves very limited options for usingTracer
device: traced packets only can be directly printed "as-is" and only in limited context (inside the closure).I'm updating API of
Tracer
device to provide access to internal fields of traced packet; this will enable implementation of custom printing or packet inspection functionsI renamed
smoltcp::phy::tracer::Packet
tosmoltcp::phy::tracer::TracerPacket
, following prefixing convention used by types declared insmoltcp::phy::pcap_writer