Giter Site home page Giter Site logo

geofft / byteorder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from burntsushi/byteorder

0.0 3.0 0.0 152 KB

Rust library for reading/writing numbers in big-endian and little-endian.

License: The Unlicense

Makefile 0.63% Vim Script 0.14% Rust 99.23%

byteorder's Introduction

This crate provides convenience methods for encoding and decoding numbers in either big-endian or little-endian order. This is meant to replace the old methods defined on the standard library Reader and Writer traits.

This crate currently supports both the std::io and std::old_io modules.

Build status

Dual-licensed under MIT or the UNLICENSE.

Documentation

http://burntsushi.net/rustdoc/byteorder/.

The documentation includes examples.

Installation

This crate works with Cargo and is on crates.io. The package is regularly updated. Add is to your Cargo.toml like so:

[dependencies]
byteorder = "*"

If you want to augment existing Reader and Writer types, then import the extension methods like so:

extern crate byteorder;

use byteorder::{ReadBytesExt, WriteBytesExt, BigEndian, LittleEndian};

Or use the ReadBytesExt/WriteBytesExt traits if you're using the new std::io module.

For example:

use std::old_io::MemReader;
use byteorder::{BigEndian, ReadBytesExt};

let mut rdr = MemReader::new(vec![2, 5, 3, 0]);
// Note that we use type parameters to indicate which kind of byte order
// we want!
assert_eq!(517, rdr.read_u16::<BigEndian>().unwrap());
assert_eq!(768, rdr.read_u16::<BigEndian>().unwrap());

byteorder's People

Contributors

andersk avatar andydude avatar apoelstra avatar blackbeam avatar burntsushi avatar codyps avatar dr-emann avatar fenhl avatar geofft avatar rkjnsn avatar sfackler avatar stebalien avatar

Watchers

 avatar  avatar  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.