Giter VIP home page Giter VIP logo

zero's Introduction

Zero

A Rust library for zero-allocation parsing of binary data.

Requires Rust version 1.6 or later (requires stable libcore for no_std).

See docs for more information.

Available on crates.io.

Build:

cargo build

Test:

cargo test

To use in your project, add to your Cargo.toml:

[dependencies]
zero = "0.1.2"

zero's People

Contributors

nrc avatar bryankadzban avatar toku-sa-n avatar kamilaborowska avatar fitzgen avatar luser avatar tesuji avatar nmlgc avatar

Stargazers

Nathaniel D. Hoffman avatar Roman Nazarov avatar  avatar  avatar  avatar Mike Frager avatar megumish avatar Ooguro Ryuuya avatar  avatar Fabian avatar Yoshi avatar Farteen avatar Basel Ajarmeh avatar Tony Holdstock-Brown avatar TAKUTO YOSHIKAI avatar Md. Abu Taher avatar Andrew Prentice avatar Sacha Arbonel avatar Salvador Guzman avatar Avery Pinko avatar Ivan Ivashchenko avatar  avatar Leonid Shirmanov avatar Sova avatar Will Hipschman avatar Jesse Wright avatar  avatar realityone avatar Miraculous Ladybugreport avatar Alexander Koz. avatar  avatar Johan Andersson avatar Graham Wihlidal avatar Arystan avatar Chris A. avatar Juri Hahn avatar Rust avatar Richard Dodd (dodj) avatar Masashi Fujita avatar Jean-Pierre De Jesus DIAZ avatar Eliza Weisman avatar Thomas Wickham avatar Emanuele Aina avatar Nikita Baksalyar avatar Mike Vegeto avatar Cameron Hart avatar

Watchers

 avatar James Cloos avatar  avatar

zero's Issues

read_str() should return a Result instead of panicking

Wasn't sure whether to file this as an issue in this crate or in your xmas-elf crate, but I chose here because the lowest-level change should be made here.

In the read_str() function, there is the potential to panic on the expect statement. When parsing a file (such as an ELF file using your xmas-elf crate), some symbols may not be encoded as UTF-8, so it'd be nice to be able to skip them and recover gracefully through a returned Result, rather than simply panicking and aborting the entire parse thread.

If you're okay with that change, I'm happy to submit a pull request to both this and the xmas-elf crate.

Also, thanks a lot for this and the xmas-elf crate, and also for making the change for my previous issue with the elf flags. It's really saved me a lot of time!!

`zero` on crates.io seems outdated

https://docs.rs/crate/zero/0.1.2/source/src/lib.rs

It doesn't check the alignment as it is on GitHub:

zero/src/lib.rs

Lines 51 to 59 in 4a72475

pub fn read_array<T: Pod>(input: &[u8]) -> &[T] {
let t_size = mem::size_of::<T>();
assert!(t_size > 0, "Can't read arrays of zero-sized types");
assert!(input.len() % t_size == 0);
let addr = input.as_ptr() as usize;
assert!(addr & (mem::align_of::<T>() - 1) == 0);
unsafe { read_array_unsafe(input) }
}

Maybe publish a new version?

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.