|
1 | 1 | # GEMINI.md |
2 | 2 |
|
3 | | -This document provides important context about the `dcsctp` project for the Gemini AI assistant. |
4 | | - |
5 | 3 | ## Project Overview |
6 | 4 |
|
7 | | -`dcsctp` is a Rust implementation of the Stream Control Transmission Protocol (SCTP) tailored for WebRTC Data Channels. It's a network programming library designed to be used in larger WebRTC applications. |
8 | | - |
9 | | -## Directory Structure |
10 | | - |
11 | | -* `.github/`: Contains GitHub Actions workflows for continuous integration. |
12 | | -* `fuzz/`: Contains fuzzing targets and related files for testing the robustness of the parser. |
13 | | -* `src/`: The main source code for the `dcsctp` library. |
14 | | - * `api/`: Public API definitions. |
15 | | - * `events.rs`: Event definitions. |
16 | | - * `fuzzer/`: Fuzzing-related utilities. |
17 | | - * `lib.rs`: The main library file. |
18 | | - * `packet/`: SCTP packet and chunk definitions and parsing logic. |
19 | | - * `rx/`: Code related to receiving data. |
20 | | - * `socket/`: The main SCTP socket implementation. |
21 | | - * `testing/`: Testing utilities and data generators. |
22 | | - * `timer.rs`: Timer-related logic. |
23 | | - * `tx/`: Code related to sending data. |
24 | | - * `types.rs`: Core data types used throughout the library. |
25 | | - |
26 | | -## Core Commands |
27 | | - |
28 | | -When working on this project, please use the following commands to ensure code quality and correctness. |
29 | | - |
30 | | -### Building the code |
31 | | - |
32 | | -To build the project, run: |
33 | | -```bash |
34 | | -cargo build |
35 | | -``` |
36 | | - |
37 | | -### Running tests |
38 | | - |
39 | | -The project has a comprehensive test suite. To run all tests, use: |
40 | | -```bash |
41 | | -cargo test |
42 | | -``` |
43 | | - |
44 | | -### Linting and formatting |
45 | | - |
46 | | -This project uses `rustfmt` for code formatting and `clippy` for linting. |
47 | | - |
48 | | -To check for formatting issues, run: |
49 | | -```bash |
50 | | -cargo +nightly fmt --all -- --check |
51 | | -``` |
52 | | - |
53 | | -To run the linter, use: |
54 | | -```bash |
55 | | -cargo clippy --all-features --all-targets -- -D warnings |
56 | | -``` |
57 | | - |
58 | | -## Project Conventions |
59 | | - |
60 | | -* The project follows standard Rust conventions. |
61 | | -* All code should be formatted with `rustfmt`. |
62 | | -* All code should pass `clippy` checks with no warnings. |
63 | | -* New features should be accompanied by unit tests. |
64 | | -* Commit messages should be clear and descriptive. |
| 5 | +`dcsctp` is a Rust implementation of the Stream Control Transmission Protocol |
| 6 | +(SCTP, [RFC 9260](https://www.rfc-editor.org/rfc/rfc9260.txt)) designed for |
| 7 | +WebRTC Data Channels ([RFC 8831](https://www.rfc-editor.org/rfc/rfc8831.txt)). |
| 8 | +It is a user-space library intended to be embedded in larger systems (like |
| 9 | +WebRTC implementations), not a standalone server or in an operating system |
| 10 | +kernel. |
| 11 | + |
| 12 | +## Architecture |
| 13 | + |
| 14 | +- **Core Design**: The library is single-threaded and event-driven. It does not |
| 15 | + perform I/O directly. The consumer drives the loop by feeding packets/timer |
| 16 | + events and handling outgoing commands. |
| 17 | +- **Entry Point**: The primary interface is the `DcSctpSocket` trait defined in |
| 18 | + `src/api/mod.rs`. Use `dcsctp::new_socket` (in `src/lib.rs`) to instantiate. |
| 19 | +- **Directory Structure**: |
| 20 | + - `src/api/`: Public API and configuration options. |
| 21 | + - `src/packet/`: Wire format parsing and serialization (Chunks, Parameters). |
| 22 | + - `src/socket/`: Main state machine and socket logic. |
| 23 | + - `src/rx/` & `src/tx/`: Receiver and Transmitter logic (reassembly, |
| 24 | + congestion control). |
| 25 | + - `src/timer/`: Timer abstractions (does not use system timers directly). |
| 26 | + - `fuzz/`: Fuzz targets. |
| 27 | +- **C++ Bindings**: `src/ffi.rs` provides C++ bindings using `cxx`. Any changes |
| 28 | + to the public API must also be added here. |
| 29 | + |
| 30 | +## Development Workflow |
| 31 | + |
| 32 | +- **Build**: `cargo build` |
| 33 | +- **Test**: `cargo test` (Runs extensive unit and integration tests). |
| 34 | +- **Lint**: `cargo clippy --all-features --all-targets -- -D warnings` |
| 35 | +- **Format**: `cargo +nightly fmt --all -- --check` |
| 36 | + |
| 37 | +## Coding Standards |
| 38 | + |
| 39 | +- **Safety**: `unsafe` code is strictly prohibited (`deny(unsafe_code)`). |
| 40 | +- **Error Handling**: Use `thiserror` for error types. Return |
| 41 | + `Result<T, Error>` for fallible operations. |
| 42 | +- **Logging**: Use the `log` crate (`trace!`, `debug!`, `info!`, `warn!`, |
| 43 | + `error!`). Do not use `println!`. |
| 44 | +- **Async**: The library is synchronous. Do not introduce `async/await` in core |
| 45 | + logic. |
| 46 | +- **Dependencies**: Keep dependencies minimal. Major ones: `log`, `thiserror`, |
| 47 | + `fastrand`. |
| 48 | + |
| 49 | +## Contribution Rules |
| 50 | + |
| 51 | +- **Changelog**: All functional changes must be documented in `CHANGELOG.md` |
| 52 | + under the *Unreleased* section (categories: Added, Changed, Deprecated, |
| 53 | + Removed, Fixed, Security). |
| 54 | +- **Commits**: Use clear, descriptive commit messages. |
| 55 | +- **Pull Requests**: One change per PR. |
0 commit comments