Skip to content

Commit 8285593

Browse files
committed
feat: initial release of the no_std COBS/COBS-R crate
Pure no_std COBS + COBS/R + framing; conforms to firechip/cobs-conformance. Signed-off-by: Alexander Salas Bastidas <ajsb85@firechip.dev>
0 parents  commit 8285593

25 files changed

Lines changed: 1582 additions & 0 deletions

.dod.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Definition of Done, shown by `tbdflow commit` before each commit.
2+
checklist:
3+
- "`cargo fmt --check` produces no changes."
4+
- "`cargo clippy --all-targets --all-features -- -D warnings` is clean."
5+
- "`cargo clippy --no-default-features -- -D warnings` is clean (no_std)."
6+
- "`cargo test` passes."
7+
- "New behaviour is covered by tests (golden vectors for codec changes)."
8+
- "CHANGELOG.md is updated for user-visible changes."
9+
- "The crate still conforms to the firechip/cobs-conformance vectors."
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Bug report
2+
description: Report incorrect encoding/decoding or another defect in cobs_codec_rs.
3+
title: "[bug]: "
4+
labels: ["bug"]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: >
9+
Thanks for filing a bug! A minimal, byte-level reproduction is the most
10+
helpful thing you can provide.
11+
- type: input
12+
id: version
13+
attributes:
14+
label: cobs_codec_rs version
15+
placeholder: "1.0.0"
16+
validations:
17+
required: true
18+
- type: input
19+
id: rustc
20+
attributes:
21+
label: Rust version (rustc --version) and target
22+
placeholder: "1.92.0, thumbv7em-none-eabihf"
23+
validations:
24+
required: true
25+
- type: dropdown
26+
id: features
27+
attributes:
28+
label: Which feature set?
29+
options:
30+
- "default (std)"
31+
- "alloc (no std)"
32+
- "no default features (no_std, no alloc)"
33+
validations:
34+
required: true
35+
- type: textarea
36+
id: what-happened
37+
attributes:
38+
label: What happened?
39+
description: Include the input bytes (hex), what you expected, and what you got.
40+
placeholder: |
41+
Input: 0x11 0x00 0x22
42+
Expected: 0x02 0x11 0x02 0x22
43+
Actual: ...
44+
validations:
45+
required: true
46+
- type: textarea
47+
id: repro
48+
attributes:
49+
label: Minimal reproduction
50+
render: rust
51+
validations:
52+
required: false

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: docs.rs API documentation
4+
url: https://docs.rs/cobs_codec_rs
5+
about: Full API reference for the crate.
6+
- name: Conformance vectors (all languages)
7+
url: https://github.com/firechip/cobs-conformance
8+
about: The shared COBS/COBS-R test vectors this crate is verified against.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Feature request
2+
description: Suggest a new capability or improvement for cobs_codec_rs.
3+
title: "[feat]: "
4+
labels: ["enhancement"]
5+
body:
6+
- type: textarea
7+
id: problem
8+
attributes:
9+
label: What problem are you trying to solve?
10+
validations:
11+
required: true
12+
- type: textarea
13+
id: proposal
14+
attributes:
15+
label: Proposed solution
16+
render: rust
17+
validations:
18+
required: false
19+
- type: checkboxes
20+
id: scope
21+
attributes:
22+
label: Scope
23+
options:
24+
- label: >
25+
I understand cobs_codec_rs aims to stay a small, no_std,
26+
dependency-free byte-stuffing crate (COBS/COBS-R + framing).
27+
required: true

.github/dependabot.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: 2
2+
updates:
3+
# Cargo dependencies (this crate has none today, but future ones + the lockfile).
4+
- package-ecosystem: "cargo"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
open-pull-requests-limit: 5
9+
labels:
10+
- "dependencies"
11+
commit-message:
12+
prefix: "deps"
13+
14+
# GitHub Actions used by the workflows.
15+
- package-ecosystem: "github-actions"
16+
directory: "/"
17+
schedule:
18+
interval: "weekly"
19+
open-pull-requests-limit: 5
20+
labels:
21+
- "dependencies"
22+
- "github-actions"
23+
commit-message:
24+
prefix: "ci"

.github/pull_request_template.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!-- Thanks for contributing to cobs_codec_rs! -->
2+
3+
## Description
4+
5+
<!-- What does this PR change, and why? Link any related issue. -->
6+
7+
## Checklist
8+
9+
- [ ] `cargo fmt --check` produces no changes
10+
- [ ] `cargo clippy --all-targets --all-features -- -D warnings` is clean
11+
- [ ] `cargo clippy --no-default-features -- -D warnings` is clean (no_std)
12+
- [ ] `cargo test` passes
13+
- [ ] Added or updated tests (golden vectors for codec changes)
14+
- [ ] Updated `CHANGELOG.md` for user-visible changes
15+
- [ ] Commits are SSH/GPG-signed and signed-off (`git commit -s`, DCO)

.github/workflows/ci.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: read
15+
16+
env:
17+
CARGO_TERM_COLOR: always
18+
RUSTFLAGS: "-D warnings"
19+
20+
jobs:
21+
check:
22+
name: fmt, clippy, test, docs
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: dtolnay/rust-toolchain@stable
27+
with:
28+
components: rustfmt, clippy
29+
- name: Formatting
30+
run: cargo fmt --check
31+
- name: Clippy (all features)
32+
run: cargo clippy --all-targets --all-features -- -D warnings
33+
- name: Clippy (no_std)
34+
run: cargo clippy --no-default-features -- -D warnings
35+
- name: Test
36+
run: cargo test --all-features
37+
- name: Docs
38+
run: cargo doc --no-deps --all-features
39+
env:
40+
RUSTDOCFLAGS: "-D warnings"
41+
42+
no-std:
43+
name: no_std build (bare metal)
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v4
47+
- uses: dtolnay/rust-toolchain@stable
48+
with:
49+
targets: thumbv7em-none-eabihf
50+
- name: Build for a no_std target
51+
run: cargo build --no-default-features --target thumbv7em-none-eabihf
52+
53+
msrv:
54+
name: minimum supported Rust (1.81)
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/checkout@v4
58+
- uses: dtolnay/rust-toolchain@1.81.0
59+
- run: cargo build --all-features
60+
61+
conformance:
62+
name: Conformance vectors
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v4
66+
- uses: dtolnay/rust-toolchain@stable
67+
- name: Download shared conformance vectors
68+
run: curl -sSfL -o vectors.jsonl https://raw.githubusercontent.com/firechip/cobs-conformance/v1.0.0/vectors/vectors.jsonl
69+
- name: Check conformance
70+
env:
71+
COBS_CONFORMANCE_VECTORS: ${{ github.workspace }}/vectors.jsonl
72+
run: cargo test --test conformance -- --nocapture

.github/workflows/commit-lint.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Commit lint
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
conventional-commits:
12+
name: Conventional Commits
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
- name: Check commit subjects follow Conventional Commits
19+
env:
20+
BASE: ${{ github.event.pull_request.base.sha }}
21+
HEAD: ${{ github.event.pull_request.head.sha }}
22+
run: |
23+
types='build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test'
24+
pattern="^(${types})(\([a-z0-9._/-]+\))?!?: .+"
25+
fail=0
26+
for sha in $(git rev-list --no-merges "$BASE..$HEAD"); do
27+
subject=$(git log -1 --format=%s "$sha")
28+
if printf '%s' "$subject" | grep -qE "$pattern"; then
29+
echo "ok: $subject"
30+
else
31+
echo "::error::Not a Conventional Commit: $subject"
32+
fail=1
33+
fi
34+
done
35+
if [ "$fail" -ne 0 ]; then
36+
echo "Commit subjects must be Conventional Commits: type(scope): subject"
37+
echo "Allowed types: ${types//|/, }"
38+
exit 1
39+
fi
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Publish crate
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
publish:
14+
name: Publish to crates.io
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: dtolnay/rust-toolchain@stable
19+
- name: Verify before publishing
20+
run: |
21+
cargo fmt --check
22+
cargo clippy --all-targets --all-features -- -D warnings
23+
cargo test --all-features
24+
- name: Publish
25+
env:
26+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
27+
run: cargo publish

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

0 commit comments

Comments
 (0)