Git Product home page Git Product logo

rust-endian's Introduction

rust-endian

Rust I/O Endianness

At the time of this writing, there are 3 Rust libraries for endianness:

  • endian -- this library
  • byteorder
  • bswap

libendian

This library adds 4 methods to integers:

fn read_be(&self, buf: &mut [u8]) -> Result<usize>;
fn read_le(&self, buf: &mut [u8]) -> Result<usize>;
fn write_be(&mut self, buf: &[u8]) -> Result<usize>;
fn write_le(&mut self, buf: &[u8]) -> Result<usize>;

libbyteorder

That other library adds several methods to existing readers and writers:

fn read_u8(&mut self) -> Result<u8>;
fn read_i8(&mut self) -> Result<i8>;
fn read_u16<T: ByteOrder>(&mut self) -> Result<u16>;
fn read_i16<T: ByteOrder>(&mut self) -> Result<i16>;
fn read_u32<T: ByteOrder>(&mut self) -> Result<u32>;
fn read_i32<T: ByteOrder>(&mut self) -> Result<i32>;
fn read_u64<T: ByteOrder>(&mut self) -> Result<u64>;
fn read_i64<T: ByteOrder>(&mut self) -> Result<i64>;
fn write_u8(&mut self, n: u8) -> Result<()>;
fn write_i8(&mut self, n: i8) -> Result<()>;
fn write_u16<T: ByteOrder>(&mut self, n: u16) -> Result<()>;
fn write_i16<T: ByteOrder>(&mut self, n: i16) -> Result<()>;
fn write_u32<T: ByteOrder>(&mut self, n: u32) -> Result<()>;
fn write_i32<T: ByteOrder>(&mut self, n: i32) -> Result<()>;
fn write_u64<T: ByteOrder>(&mut self, n: u64) -> Result<()>;
fn write_i64<T: ByteOrder>(&mut self, n: i64) -> Result<()>;

Conclusion

It looks like libbyteorder might be the better choice, but that is yet to be determined, until then, I think that the libendian might have some valid use cases that the other does not provide for.

rust-endian's People

Contributors

andydude avatar

Stargazers

Doug Tangren avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.