-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
243 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[build] | ||
rustdocflags = ["--cfg", "docsrs"] | ||
|
||
[env] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
github: rkyv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "0 10 * * *" | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
RUSTFLAGS: -Dwarnings | ||
|
||
jobs: | ||
features: | ||
name: Features / ${{ matrix.std }} ${{ matrix.derive }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
bytecheck: | ||
- '' | ||
- bytecheck | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
- run: cargo test --verbose --tests --no-default-features --features "${{ matrix.bytecheck }}" | ||
|
||
toolchain: | ||
name: Toolchain / ${{ matrix.toolchain }} ${{ matrix.opt }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
toolchain: | ||
- stable | ||
- beta | ||
- nightly | ||
opt: | ||
- '' | ||
- --release | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: ${{ matrix.toolchain }} | ||
- run: cargo test --verbose ${{ matrix.opt }} | ||
|
||
miri: | ||
name: Miri / ${{ matrix.opt }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
opt: | ||
- '' | ||
- --release | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@miri | ||
- run: cargo miri setup | ||
- run: cargo miri test ${{ matrix.opt }} --verbose | ||
env: | ||
MIRIFLAGS: -Zmiri-disable-stacked-borrows -Zmiri-tree-borrows | ||
|
||
test: | ||
name: Test / ${{ matrix.target }} ${{ matrix.opt }} | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
opt: | ||
- '' | ||
- --release | ||
include: | ||
- os: ubuntu-latest | ||
target: x86_64-unknown-linux-gnu | ||
- os: macos-latest | ||
target: aarch64-apple-darwin | ||
- os: windows-latest | ||
target: x86_64-pc-windows-msvc | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
- run: cargo test ${{ matrix.opt }} | ||
|
||
cross: | ||
name: Cross / ${{ matrix.target }} | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
target: | ||
- i686-unknown-linux-gnu | ||
- i586-unknown-linux-gnu | ||
- armv7-unknown-linux-gnueabihf | ||
- aarch64-unknown-linux-gnu | ||
- thumbv6m-none-eabi | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
- run: cargo install cross | ||
- run: cross build --no-default-features --features "bytecheck" --target ${{ matrix.target }} --verbose | ||
|
||
format: | ||
name: Format | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@nightly | ||
with: | ||
components: rustfmt | ||
- run: cargo fmt --check | ||
|
||
clippy: | ||
name: Clippy | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@nightly | ||
with: | ||
components: clippy | ||
- run: cargo clippy | ||
|
||
doc: | ||
name: Doc | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@nightly | ||
- run: cargo doc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,30 @@ | ||
rend is a library that provides endian-aware primitives for Rust. | ||
|
||
--- | ||
|
||
## rend in action | ||
|
||
```rust | ||
use rend::*; | ||
|
||
let little_int = i32_le::from_native(0x12345678); | ||
// Internal representation is little-endian | ||
assert_eq!( | ||
[0x78, 0x56, 0x34, 0x12], | ||
unsafe { ::core::mem::transmute::<_, [u8; 4]>(little_int) } | ||
); | ||
|
||
// Can also be made with `.into()` | ||
let little_int: i32_le = 0x12345678.into(); | ||
// Still formats correctly | ||
assert_eq!("305419896", format!("{}", little_int)); | ||
assert_eq!("0x12345678", format!("0x{:x}", little_int)); | ||
|
||
let big_int = i32_be::from_native(0x12345678); | ||
// Internal representation is big-endian | ||
assert_eq!( | ||
[0x12, 0x34, 0x56, 0x78], | ||
unsafe { ::core::mem::transmute::<_, [u8; 4]>(big_int) } | ||
); | ||
|
||
// Can also be made with `.into()` | ||
let big_int: i32_be = 0x12345678.into(); | ||
// Still formats correctly | ||
assert_eq!("305419896", format!("{}", big_int)); | ||
assert_eq!("0x12345678", format!("0x{:x}", big_int)); | ||
``` | ||
```rust | ||
use core::mem::transmute; | ||
use rend::*; | ||
|
||
let little_int = i32_le::from_native(0x12345678); | ||
// Internal representation is little-endian | ||
assert_eq!( | ||
[0x78, 0x56, 0x34, 0x12], | ||
unsafe { transmute::<_, [u8; 4]>(little_int) } | ||
); | ||
|
||
// Can also be made with `.into()` | ||
let little_int: i32_le = 0x12345678.into(); | ||
// Still formats correctly | ||
assert_eq!("305419896", format!("{}", little_int)); | ||
assert_eq!("0x12345678", format!("0x{:x}", little_int)); | ||
|
||
let big_int = i32_be::from_native(0x12345678); | ||
// Internal representation is big-endian | ||
assert_eq!( | ||
[0x12, 0x34, 0x56, 0x78], | ||
unsafe { transmute::<_, [u8; 4]>(big_int) } | ||
); | ||
|
||
// Can also be made with `.into()` | ||
let big_int: i32_be = 0x12345678.into(); | ||
// Still formats correctly | ||
assert_eq!("305419896", format!("{}", big_int)); | ||
assert_eq!("0x12345678", format!("0x{:x}", big_int)); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
max_width = 80 | ||
comment_width = 80 | ||
wrap_comments = true | ||
group_imports = "StdExternalCrate" | ||
imports_granularity = "Crate" | ||
condense_wildcard_suffixes = true | ||
error_on_line_overflow = true | ||
error_on_unformatted = true | ||
format_code_in_doc_comments = true | ||
format_macro_matchers = true | ||
format_macro_bodies = true | ||
format_strings = true | ||
hex_literal_case = "Lower" | ||
normalize_comments = true | ||
use_field_init_shorthand = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.