-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: bump version to 0.10. move scroll_derive into scroll
- Loading branch information
Showing
8 changed files
with
611 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = ".." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
Oops, something went wrong.