mirror of
https://codeberg.org/icewind/bitbuffer.git
synced 2026-06-03 08:34:07 +02:00
switch flake setup
This commit is contained in:
parent
d989565775
commit
25e7d443b5
4 changed files with 92 additions and 226 deletions
88
.github/workflows/ci.yaml
vendored
88
.github/workflows/ci.yaml
vendored
|
|
@ -3,7 +3,7 @@ on: [push, pull_request]
|
||||||
name: Continuous integration
|
name: Continuous integration
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
checks:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
@ -12,76 +12,17 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: ci
|
name: ci
|
||||||
instance: https://cache.icewind.me
|
instance: https://cache.icewind.me
|
||||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
authToken: "${{ secrets.ATTIC_TOKEN }}"
|
||||||
- run: nix build .#check
|
- run: nix flake check --keep-going
|
||||||
|
|
||||||
msrv:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: check
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: cachix/install-nix-action@v27
|
|
||||||
- uses: icewind1991/attic-action@v1
|
|
||||||
with:
|
|
||||||
name: ci
|
|
||||||
instance: https://cache.icewind.me
|
|
||||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
|
||||||
- run: nix build .#msrv
|
|
||||||
|
|
||||||
clippy:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: check
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: cachix/install-nix-action@v27
|
|
||||||
- uses: icewind1991/attic-action@v1
|
|
||||||
with:
|
|
||||||
name: ci
|
|
||||||
instance: https://cache.icewind.me
|
|
||||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
|
||||||
- run: nix build .#clippy
|
|
||||||
|
|
||||||
tests:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: check
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: cachix/install-nix-action@v27
|
|
||||||
- uses: icewind1991/attic-action@v1
|
|
||||||
with:
|
|
||||||
name: ci
|
|
||||||
instance: https://cache.icewind.me
|
|
||||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
|
||||||
- run: nix build .#test
|
|
||||||
|
|
||||||
fmt:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: cachix/install-nix-action@v27
|
|
||||||
- uses: icewind1991/attic-action@v1
|
|
||||||
with:
|
|
||||||
name: ci
|
|
||||||
instance: https://cache.icewind.me
|
|
||||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
|
||||||
- run: nix build .#fmt
|
|
||||||
|
|
||||||
miri-matrix:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: cachix/install-nix-action@v27
|
|
||||||
- id: set-matrix
|
|
||||||
run: echo "matrix={\"target\":$(nix eval --json ".#miriTargets.x86_64-linux")}" | tee $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
miri-tests:
|
miri-tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [tests, miri-matrix]
|
needs: [checks]
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix: ${{fromJson(needs.miri-matrix.outputs.matrix)}}
|
matrix:
|
||||||
|
toolchain:
|
||||||
|
["x86_64-unknown-linux-musl", "mips64-unknown-linux-gnuabi64"]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: cachix/install-nix-action@v27
|
- uses: cachix/install-nix-action@v27
|
||||||
|
|
@ -89,13 +30,18 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: ci
|
name: ci
|
||||||
instance: https://cache.icewind.me
|
instance: https://cache.icewind.me
|
||||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
authToken: "${{ secrets.ATTIC_TOKEN }}"
|
||||||
- run: nix develop .#miri -c cargo miri test --target ${{ matrix.target }}
|
- run: nix run .#miri -- test --target ${{ matrix.target }}
|
||||||
|
|
||||||
semver:
|
semver:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: check
|
needs: checks
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Check semver
|
- uses: cachix/install-nix-action@v27
|
||||||
uses: obi1kenobi/cargo-semver-checks-action@v2
|
- uses: icewind1991/attic-action@v1
|
||||||
|
with:
|
||||||
|
name: ci
|
||||||
|
instance: https://cache.icewind.me
|
||||||
|
authToken: "${{ secrets.ATTIC_TOKEN }}"
|
||||||
|
- run: nix run .#semver-checks
|
||||||
|
|
|
||||||
22
README.md
22
README.md
|
|
@ -10,19 +10,19 @@ The main way of reading the binary data is to first create a `BitReadBuffer` ,wr
|
||||||
|
|
||||||
Once you have a BitStream, there are 2 different approaches of reading data
|
Once you have a BitStream, there are 2 different approaches of reading data
|
||||||
|
|
||||||
- read primitives, Strings and byte arrays, using `read_bool`, `read_int`, `read_float`, `read_bytes` and `read_string`
|
- read primitives, Strings and byte arrays, using `read_bool`, `read_int`, `read_float`, `read_bytes` and `read_string`
|
||||||
- read any type implementing the `BitRead` or `BitReadSized` traits using `read` and `read_sized`
|
- read any type implementing the `BitRead` or `BitReadSized` traits using `read` and `read_sized`
|
||||||
- `BitRead` is for types that can be read without requiring any size info (e.g. null-terminal strings, floats, whole integers, etc)
|
- `BitRead` is for types that can be read without requiring any size info (e.g. null-terminal strings, floats, whole integers, etc)
|
||||||
- `BitReadSized` is for types that require external sizing information to be read (fixed length strings, arbitrary length integers
|
- `BitReadSized` is for types that require external sizing information to be read (fixed length strings, arbitrary length integers
|
||||||
|
|
||||||
The `BitRead` and `BitReadSized` traits can be used with `#[derive]` if all fields implement `BitRead` or `BitReadSized`.
|
The `BitRead` and `BitReadSized` traits can be used with `#[derive]` if all fields implement `BitRead` or `BitReadSized`.
|
||||||
|
|
||||||
For writing the data you wrap the output `Vec` into a `BitWriteStream` which can then be used in a manner similar to the `BitReadStream`
|
For writing the data you wrap the output `Vec` into a `BitWriteStream` which can then be used in a manner similar to the `BitReadStream`
|
||||||
|
|
||||||
- write primitives, Strings and byte arrays, using `write_bool`, `write_int`, `write_float`, `write_bytes` and `write_string`
|
- write primitives, Strings and byte arrays, using `write_bool`, `write_int`, `write_float`, `write_bytes` and `write_string`
|
||||||
- write any type implementing the `BitWrite` or `BitWriteSized` traits using `write` and `write_sized`
|
- write any type implementing the `BitWrite` or `BitWriteSized` traits using `write` and `write_sized`
|
||||||
- `BitWrite` is for types that can be written without requiring any size info (e.g. null-terminal strings, floats, whole integers, etc)
|
- `BitWrite` is for types that can be written without requiring any size info (e.g. null-terminal strings, floats, whole integers, etc)
|
||||||
- `BitWriteSized` is for types that require external sizing information to be written (fixed length strings, arbitrary length integers
|
- `BitWriteSized` is for types that require external sizing information to be written (fixed length strings, arbitrary length integers
|
||||||
|
|
||||||
Just like the read counterparts, `BitWrite` and `BitWriteSized` traits can be used with `#[derive]` if all fields implement `BitWrite` or `BitWriteSized`.
|
Just like the read counterparts, `BitWrite` and `BitWriteSized` traits can be used with `#[derive]` if all fields implement `BitWrite` or `BitWriteSized`.
|
||||||
|
|
||||||
|
|
@ -56,14 +56,14 @@ write_stream.write(&ComplexType {
|
||||||
second: 12,
|
second: 12,
|
||||||
third: true
|
third: true
|
||||||
})?;
|
})?;
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Licensed under either of
|
Licensed under either of
|
||||||
|
|
||||||
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
|
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
|
||||||
* MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)
|
- MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
at your option.
|
at your option.
|
||||||
|
|
||||||
|
|
|
||||||
103
flake.lock
generated
103
flake.lock
generated
|
|
@ -1,32 +1,69 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"naersk": {
|
"crane": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1727060013,
|
||||||
|
"narHash": "sha256-/fC5YlJy4IoAW9GhkJiwyzk0K/gQd9Qi4rRcoweyG9E=",
|
||||||
|
"owner": "ipetkov",
|
||||||
|
"repo": "crane",
|
||||||
|
"rev": "6b40cc876c929bfe1e3a24bf538ce3b5622646ba",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "ipetkov",
|
||||||
|
"repo": "crane",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flakelight": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1721727458,
|
"lastModified": 1727095190,
|
||||||
"narHash": "sha256-r/xppY958gmZ4oTfLiHN0ZGuQ+RSTijDblVgVLFi1mw=",
|
"narHash": "sha256-eZfUxkPefTP5fknpr2/X+snNysEj830Ft1IaW7VafFE=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "naersk",
|
"repo": "flakelight",
|
||||||
"rev": "3fb418eaf352498f6b6c30592e3beb63df42ef11",
|
"rev": "9e0f7e360688187ed3d7d8b033028e0d3473aa2c",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "naersk",
|
"repo": "flakelight",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mill-scale": {
|
||||||
|
"inputs": {
|
||||||
|
"crane": "crane",
|
||||||
|
"flakelight": [
|
||||||
|
"flakelight"
|
||||||
|
],
|
||||||
|
"rust-overlay": "rust-overlay"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1727556185,
|
||||||
|
"narHash": "sha256-pEUzAE5WRpPGQYeG/U2mftfHAn2q4aO1pefJNY2EoVw=",
|
||||||
|
"owner": "icewind1991",
|
||||||
|
"repo": "mill-scale",
|
||||||
|
"rev": "823fb3493cb4838c81627821f383af918db33a7f",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "icewind1991",
|
||||||
|
"repo": "mill-scale",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1726838390,
|
"lastModified": 1726969270,
|
||||||
"narHash": "sha256-NmcVhGElxDbmEWzgXsyAjlRhUus/nEqPC5So7BOJLUM=",
|
"narHash": "sha256-8fnFlXBgM/uSvBlLWjZ0Z0sOdRBesyNdH0+esxqizGc=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "944b2aea7f0a2d7c79f72468106bc5510cbf5101",
|
"rev": "23cbb250f3bf4f516a2d0bf03c51a30900848075",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -37,24 +74,25 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"naersk": "naersk",
|
"flakelight": "flakelight",
|
||||||
"nixpkgs": "nixpkgs",
|
"mill-scale": "mill-scale",
|
||||||
"rust-overlay": "rust-overlay",
|
"nixpkgs": "nixpkgs"
|
||||||
"utils": "utils"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rust-overlay": {
|
"rust-overlay": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
|
"mill-scale",
|
||||||
|
"flakelight",
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1726972233,
|
"lastModified": 1727058553,
|
||||||
"narHash": "sha256-FlL/bNESOtDQoczRhmPfReNAmLqVg+dAX4HectPOOf0=",
|
"narHash": "sha256-tY/UU3Qk5gP/J0uUM4DZ6wo4arNLGAVqLKBotILykfQ=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "36d73192555e569d27579f6c486fea3ab768823c",
|
"rev": "edc5b0f896170f07bd39ad59d6186fcc7859bbb2",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -62,39 +100,6 @@
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"systems": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"utils": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1726560853,
|
|
||||||
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|
|
||||||
107
flake.nix
107
flake.nix
|
|
@ -1,101 +1,16 @@
|
||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "nixpkgs/nixos-24.05";
|
nixpkgs.url = "nixpkgs/nixos-24.05";
|
||||||
utils.url = "github:numtide/flake-utils";
|
flakelight = {
|
||||||
naersk.url = "github:nix-community/naersk";
|
url = "github:nix-community/flakelight";
|
||||||
naersk.inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
};
|
||||||
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
mill-scale = {
|
||||||
|
url = "github:icewind1991/mill-scale";
|
||||||
|
inputs.flakelight.follows = "flakelight";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
outputs = { mill-scale, ... }: mill-scale ./. {
|
||||||
|
devShell.packages = pkgs: with pkgs; [ cargo-expand ];
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = {
|
|
||||||
self,
|
|
||||||
nixpkgs,
|
|
||||||
utils,
|
|
||||||
naersk,
|
|
||||||
rust-overlay,
|
|
||||||
}:
|
|
||||||
utils.lib.eachDefaultSystem (system: let
|
|
||||||
overlays = [ (import rust-overlay) ];
|
|
||||||
pkgs = import nixpkgs {
|
|
||||||
inherit system overlays;
|
|
||||||
};
|
|
||||||
inherit (pkgs) lib callPackage rust-bin mkShell;
|
|
||||||
inherit (builtins) listToAttrs fromTOML readFile;
|
|
||||||
inherit (lib.sources) sourceByRegex;
|
|
||||||
|
|
||||||
toolchain = rust-bin.stable.latest.default;
|
|
||||||
msrv = (fromTOML (readFile ./Cargo.toml)).package.rust-version;
|
|
||||||
msrvToolchain = rust-bin.stable."${msrv}".default;
|
|
||||||
miriToolchain = rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override {
|
|
||||||
extensions = [ "miri" "rust-src" ];
|
|
||||||
});
|
|
||||||
|
|
||||||
naersk' = callPackage naersk {
|
|
||||||
rustc = toolchain;
|
|
||||||
cargo = toolchain;
|
|
||||||
};
|
|
||||||
msrvNaersk = callPackage naersk {
|
|
||||||
rustc = msrvToolchain;
|
|
||||||
cargo = msrvToolchain;
|
|
||||||
};
|
|
||||||
src = sourceByRegex ./. ["Cargo.*" "(src|tests|bitbuffer_derive|benches)(/.*)?"];
|
|
||||||
|
|
||||||
naerskOpt = {
|
|
||||||
pname = "bitbuffer";
|
|
||||||
root = src;
|
|
||||||
copySources = ["bitbuffer_derive"];
|
|
||||||
};
|
|
||||||
in rec {
|
|
||||||
packages = {
|
|
||||||
check = naersk'.buildPackage (naerskOpt // {
|
|
||||||
mode = "check";
|
|
||||||
});
|
|
||||||
test = naersk'.buildPackage (naerskOpt // {
|
|
||||||
mode = "test";
|
|
||||||
cargoTestOptions = x: x ++ ["--all-features"];
|
|
||||||
});
|
|
||||||
clippy = naersk'.buildPackage (naerskOpt // {
|
|
||||||
mode = "clippy";
|
|
||||||
});
|
|
||||||
fmt = naersk'.buildPackage (naerskOpt // {
|
|
||||||
mode = "fmt";
|
|
||||||
});
|
|
||||||
msrv = msrvNaersk.buildPackage (naerskOpt // {
|
|
||||||
mode = "check";
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
miriTargets = [
|
|
||||||
"x86_64-unknown-linux-musl" # little-endian
|
|
||||||
"mips64-unknown-linux-gnuabi64" # big-endian
|
|
||||||
];
|
|
||||||
|
|
||||||
devShells = let
|
|
||||||
tools = with pkgs; [
|
|
||||||
bacon
|
|
||||||
cargo-edit
|
|
||||||
cargo-outdated
|
|
||||||
(writeShellApplication {
|
|
||||||
name = "cargo-expand";
|
|
||||||
runtimeInputs = [cargo-expand toolchain];
|
|
||||||
text = ''
|
|
||||||
# shellcheck disable=SC2068
|
|
||||||
RUSTC_BOOTSTRAP=1 cargo-expand $@
|
|
||||||
'';
|
|
||||||
})
|
|
||||||
cargo-semver-checks
|
|
||||||
];
|
|
||||||
in {
|
|
||||||
default = mkShell {
|
|
||||||
nativeBuildInputs = [toolchain] ++ tools;
|
|
||||||
};
|
|
||||||
msrv = mkShell {
|
|
||||||
nativeBuildInputs = [msrvToolchain] ++ tools;
|
|
||||||
};
|
|
||||||
miri = mkShell {
|
|
||||||
nativeBuildInputs = [miriToolchain] ++ tools;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue