Skip to content

Commit

Permalink
build: bump version to 0.10. move scroll_derive into scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
m4b committed Nov 1, 2018
1 parent 1532d73 commit e0fdafe
Show file tree
Hide file tree
Showing 8 changed files with 611 additions and 9 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "scroll"
version = "0.9.2"
version = "0.10.0"
authors = ["m4b <m4b.github.io@gmail.com>", "Ted Mielczarek <ted@mielczarek.org>"]
readme = "README.md"
keywords = ["bytes", "endian", "immutable", "pread", "pwrite"]
Expand All @@ -10,7 +10,7 @@ documentation = "https://docs.rs/scroll"
description = "A suite of powerful, extensible, generic, endian-aware Read/Write traits for byte buffers"

[dependencies]
scroll_derive = { version = "0.9", optional = true }
scroll_derive = { version = "0.10", optional = true, path = "scroll_derive" }

[build-dependencies]
rustc_version = "0.2"
Expand All @@ -21,5 +21,5 @@ std = []
derive = ["scroll_derive"]

[dev-dependencies]
rayon = "1.0.0"
byteorder = "1.0.0"
rayon = "1"
byteorder = "1"
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ https://docs.rs/scroll

Add to your `Cargo.toml`

```toml
```toml, no_test
[dependencies]
scroll = "0.9"
scroll = "0.10"
```

### Overview
Expand Down Expand Up @@ -83,7 +83,9 @@ fn main() {

Scroll implements a custom derive that can provide `Pread` and `Pwrite` implementations for your structs.

``` rust
```no_test
#[macro_use]
extern crate scroll_derive;
#[macro_use]
extern crate scroll;
Expand Down Expand Up @@ -118,9 +120,9 @@ fn main() {

This feature is **not** enabled by default, you must enable the `derive` feature in Cargo.toml to use it:

```toml
```toml, no_test
[dependencies]
scroll = { version = "0.9", features = ["derive"] }
scroll = { version = "0.10", features = ["derive"] }
```

# `std::io` API
Expand Down
22 changes: 22 additions & 0 deletions scroll_derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "scroll_derive"
version = "0.10.0"
authors = ["m4b <m4b.github.io@gmail.com>", "Ted Mielczarek <ted@mielczarek.org>"]
readme = "README.md"
keywords = ["derive", "macros", "pread", "pwrite", "bytes"]
repository = "https://github.com/m4b/scroll_derive"
license = "MIT"
documentation = "https://docs.rs/scroll_derive"
description = "A macros 1.1 derive implementation for Pread and Pwrite traits from the scroll crate"

[lib]
proc-macro = true

[dependencies]
proc-macro2 = "0.4"
quote = "0.6"
syn = "0.15"

[dev-dependencies.scroll]
version = "0.10"
path = ".."
21 changes: 21 additions & 0 deletions scroll_derive/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
35 changes: 35 additions & 0 deletions scroll_derive/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# scroll_derive
Macros 1.1 implementing #[derive(Pread, Pwrite)] for https://github.com/m4b/scroll

Add derive annotations to your POD seamlessly and easily:

```rust
extern crate scroll;
#[macro_use]
extern crate scroll_derive;

#[derive(Debug, PartialEq, Pread, Pwrite, IOread, IOwrite, SizeWith)]
#[repr(C)]
struct Data {
id: u32,
timestamp: f64,
arr: [u16; 2],
}

use scroll::{Pread, Pwrite, Cread, LE};

fn main (){
let bytes = [0xefu8, 0xbe, 0xad, 0xde, 0, 0, 0, 0, 0, 0, 224, 63, 0xad, 0xde, 0xef, 0xbe];
let data: Data = bytes.pread_with(0, LE).unwrap();
println!("data: {:?}", &data);
assert_eq!(data.id, 0xdeadbeefu32);
let mut bytes2 = vec![0; ::std::mem::size_of::<Data>()];
bytes2.pwrite_with(data, 0, LE).unwrap();
let data: Data = bytes.pread_with(0, LE).unwrap();
let data2: Data = bytes2.pread_with(0, LE).unwrap();
assert_eq!(data, data2);

let data: Data = bytes.cread_with(0, LE);
assert_eq!(data, data2);
}
```
28 changes: 28 additions & 0 deletions scroll_derive/examples/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
extern crate scroll;
#[macro_use]
extern crate scroll_derive;

#[derive(Debug, PartialEq, Pread, Pwrite, IOread, IOwrite, SizeWith)]
#[repr(C)]
struct Data {
id: u32,
timestamp: f64,
arr: [u16; 2],
}

use scroll::{Pread, Pwrite, Cread, LE};

fn main () {
let bytes = [0xefu8, 0xbe, 0xad, 0xde, 0, 0, 0, 0, 0, 0, 224, 63, 0xad, 0xde, 0xef, 0xbe];
let data: Data = bytes.pread_with(0, LE).unwrap();
println!("data: {:?}", &data);
assert_eq!(data.id, 0xdeadbeefu32);
let mut bytes2 = vec![0; ::std::mem::size_of::<Data>()];
bytes2.pwrite_with(data, 0, LE).unwrap();
let data: Data = bytes.pread_with(0, LE).unwrap();
let data2: Data = bytes2.pread_with(0, LE).unwrap();
assert_eq!(data, data2);

let data: Data = bytes.cread_with(0, LE);
assert_eq!(data, data2);
}
Loading

0 comments on commit e0fdafe

Please sign in to comment.