#endian #cross-platform #primitive

no-std rend

Cross-platform, endian-aware primitives for Rust

30 releases

0.5.3 Sep 29, 2025
0.5.2 Oct 10, 2024
0.5.1 Sep 13, 2024
0.5.0-pre6 Jan 1, 2024
0.3.1 Jul 6, 2021

#204 in Encoding

Download history 920333/week @ 2025-08-28 984316/week @ 2025-09-04 971829/week @ 2025-09-11 998717/week @ 2025-09-18 1042063/week @ 2025-09-25 1012216/week @ 2025-10-02 992409/week @ 2025-10-09 1012716/week @ 2025-10-16 1117536/week @ 2025-10-23 1134265/week @ 2025-10-30 1140444/week @ 2025-11-06 1242360/week @ 2025-11-13 1174045/week @ 2025-11-20 866022/week @ 2025-11-27 1334915/week @ 2025-12-04 835504/week @ 2025-12-11

4,459,718 downloads per month
Used in 992 crates (6 directly)

MIT license

93KB
2.5K SLoC

rend

crates.io badge docs badge license badge

rend provides cross-platform, endian-aware primitives for Rust.

Documentation

  • rend, provides cross-platform, endian-aware primitives for Rust

Example

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));

Dependencies

~0–315KB