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

Reorganise source code #210

Merged
merged 7 commits into from
Oct 31, 2024
Merged

Reorganise source code #210

merged 7 commits into from
Oct 31, 2024

Conversation

martinling
Copy link
Member

Apart from the backend directory, the Packetry source code is currently one big bucket of code. Some of the files, particularly capture.rs, are huge. There is no index of what lives where. This makes it difficult for new contributors to find their way around and get started.

This PR tries to make it a bit easier for people to find their way around the source code. The main changes are:

  • A top-level comment is added to each file to provide an overview of its contents.
  • All UI-related code is moved into the ui module (tree_list_model, model, row_data, item_widget, record_ui and test_replay).
  • The database primitives are moved into a new database module (stream, data_stream, index_stream and compact_index).
  • The tree item API is split out of capture into a new item module (ItemSource, TrafficItem, DeviceItem etc) .
  • All general utility code is moved into the util module.

This leaves a much more manageable set of files at the top level, including:

  • Standalone programs (main.rs, cli.rs and fuzzer.rs)
  • The build script and version info (build.rs and version.rs)
  • The key modules that contain most of the core functionality (usb.rs, decoder.rs, capture.rs, item.rs, pcap.rs)

There is further work that could be done to break some of the larger files down further and add commentary, but I think this makes for a reasonable start.

There are no functional changes. This PR is purely reorganisation.

These types define the items shown in tree views, and the API for
fetching and querying them.

This API is effectively a separate layer on top of the capture
database, so it makes sense to split it out.

Move the Bytes type to util.rs and the InterfaceEpNum type to
usb.rs, as these need to be used by both capture.rs and item.rs.
@miek miek merged commit 1901bac into greatscottgadgets:main Oct 31, 2024
10 checks passed
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.

2 participants