BurntSushi / BurntSushi/byteorder

`Endianess` enum for runtime cases

Open
#95 29 comments 15 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.1k
Forks
161
PR merge metrics
No merged PRs in 30d

Description

From a discussion on `#rust-beginners` there seems to be a need for `ByteOrder` implementation that dispatches to LE/BE based on runtime information.

Essentially something like this:

```rust
enum Endianess { Little, Big }
impl ByteOrder for Endianess {
// boilerplate methods with `match` that dispatch to LE or BE
}

let endianess = get_endianess_at_runtime();
endianess.read_i32(&some_bytes);
```

The `byteorder` docs don't seem to say that the crate is focused solely on static/type-level checking, so I'm guessing this would be in scope for the library.

Of course this isn't strictly necessary, as you can probably just write reading/writing code generically and simply move the `LE`/`BE` decision to a higher level, but it may simplify some use cases regardless.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading the ByteOrder trait and the existing LE and BE implementations described in the issue. Compare the proposed Endianess variants with the current dispatch methods, then check the discussion for an agreed API; done means runtime selection can dispatch all required reads and writes without changing existing static implementations.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.