Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Byte-order-aware numeric types.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
NotificationsYou must be signed in to change notification settings

rust-osdev/endian-num

Repository files navigation

Crates.iodocs.rsCI

This crate provides theBe (big-endian) andLe (little-endian) byte-order-aware numeric types.

Unlike the popularbyteorder crate, which focuses on the action of encoding and decoding numbers to and from byte streams, this crate focuses on the state of numbers.This is useful to create structs that contain fields of a specific endianness for interoperability, such as in virtio.In comparison to other crates that focus on state, this crate closely follows naming conventions fromcore::num, has rich functionality, and extensive documentation of each method.

The core API looksroughly like this (correspondingly forBe):

#[repr(transparent)]pubstruct<T>Le(pubT);implLe<T:Integer>{pubconstfnfrom_ne(n:T) ->Self;pubconstfnfrom_be(n:Be<T>) ->Self;pubconstfnto_ne(self) ->T;pubconstfnto_be(self) ->Be<T>;pubconstfnto_be_bytes(self) ->[u8; mem::size_of::<Self>()];pubconstfnto_le_bytes(self) ->[u8; mem::size_of::<Self>()];pubconstfnto_ne_bytes(self) ->[u8; mem::size_of::<Self>()];pubconstfnfrom_be_bytes(bytes:[u8; mem::size_of::<Self>()]) ->Self;pubconstfnfrom_le_bytes(bytes:[u8; mem::size_of::<Self>()]) ->Self;pubconstfnfrom_ne_bytes(bytes:[u8; mem::size_of::<Self>()]) ->Self;}

The types also implement appropriate traits fromcore::cmp,core::convert,core::fmt, andcore::ops and provide additional helper methods for computations.

For API documentation, see thedocs.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submittedfor inclusion in the work by you, as defined in the Apache-2.0 license, shall bedual licensed as above, without any additional terms or conditions.

About

Byte-order-aware numeric types.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp