Update to 0.8.0

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
epel9
Igor Gnatenko 7 years ago
parent 970db1e9c2
commit 12bdd1e0dd

1
.gitignore vendored

@ -1 +1,2 @@
/scroll-0.7.0.crate /scroll-0.7.0.crate
/scroll-0.8.0.crate

@ -1,156 +0,0 @@
From 39e05345064ec1783f58a14ce896d521ef3cfc3a Mon Sep 17 00:00:00 2001
From: m4b <m4b.github.io@gmail.com>
Date: Sat, 2 Dec 2017 00:56:46 -0800
Subject: [PATCH] build: make tests more robust on various architectures for
smaller pointers + different endianness. ref #20
---
src/greater.rs | 10 +++++-----
src/lesser.rs | 6 +++---
src/lib.rs | 5 ++++-
tests/api.rs | 12 ++++++------
4 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/src/greater.rs b/src/greater.rs
index 99560b1..cffdbbf 100644
--- a/src/greater.rs
+++ b/src/greater.rs
@@ -60,7 +60,7 @@ pub trait Cread<Ctx, I = usize> : Index<I> + Index<RangeFrom<I>>
/// use scroll::Cread;
///
/// let bytes = [0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xef,0xbe,0x00,0x00,];
- /// let foo = bytes.cread::<usize>(0);
+ /// let foo = bytes.cread::<i64>(0);
/// let bar = bytes.cread::<u32>(8);
/// assert_eq!(foo, 1);
/// assert_eq!(bar, 0xbeef);
@@ -108,9 +108,9 @@ pub trait Cwrite<Ctx: Copy, I = usize>: Index<I> + IndexMut<RangeFrom<I>> {
/// ```
/// use scroll::{Cwrite, Cread};
/// let mut bytes = [0x0; 0x10];
- /// bytes.cwrite::<usize>(42, 0);
+ /// bytes.cwrite::<i64>(42, 0);
/// bytes.cwrite::<u32>(0xdeadbeef, 8);
- /// assert_eq!(bytes.cread::<usize>(0), 42);
+ /// assert_eq!(bytes.cread::<i64>(0), 42);
/// assert_eq!(bytes.cread::<u32>(8), 0xdeadbeef);
#[inline]
fn cwrite<N: IntoCtx<Ctx, <Self as Index<RangeFrom<I>>>::Output>>(&mut self, n: N, offset: I) where Ctx: Default {
@@ -124,9 +124,9 @@ pub trait Cwrite<Ctx: Copy, I = usize>: Index<I> + IndexMut<RangeFrom<I>> {
/// ```
/// use scroll::{Cwrite, Cread, LE, BE};
/// let mut bytes = [0x0; 0x10];
- /// bytes.cwrite_with::<usize>(42, 0, LE);
+ /// bytes.cwrite_with::<i64>(42, 0, LE);
/// bytes.cwrite_with::<u32>(0xdeadbeef, 8, BE);
- /// assert_eq!(bytes.cread::<usize>(0), 42);
+ /// assert_eq!(bytes.cread::<i64>(0), 42);
/// assert_eq!(bytes.cread::<u32>(8), 0xefbeadde);
#[inline]
fn cwrite_with<N: IntoCtx<Ctx, <Self as Index<RangeFrom<I>>>::Output>>(&mut self, n: N, offset: I, ctx: Ctx) {
diff --git a/src/lesser.rs b/src/lesser.rs
index 1258216..a26042a 100644
--- a/src/lesser.rs
+++ b/src/lesser.rs
@@ -15,13 +15,13 @@ use ctx::{FromCtx, IntoCtx, SizeWith};
///
/// #[repr(packed)]
/// struct Foo {
-/// foo: usize,
+/// foo: i64,
/// bar: u32,
/// }
///
/// impl ctx::FromCtx<scroll::Endian> for Foo {
/// fn from_ctx(bytes: &[u8], ctx: scroll::Endian) -> Self {
-/// Foo { foo: bytes.pread_with::<usize>(0, ctx).unwrap(), bar: bytes.pread_with::<u32>(8, ctx).unwrap() }
+/// Foo { foo: bytes.pread_with::<i64>(0, ctx).unwrap(), bar: bytes.pread_with::<u32>(8, ctx).unwrap() }
/// }
/// }
///
@@ -35,7 +35,7 @@ use ctx::{FromCtx, IntoCtx, SizeWith};
///
/// let bytes_ = [0x0b,0x0b,0x00,0x00,0x00,0x00,0x00,0x00, 0xef,0xbe,0x00,0x00,];
/// let mut bytes = Cursor::new(bytes_);
-/// let foo = bytes.ioread::<usize>().unwrap();
+/// let foo = bytes.ioread::<i64>().unwrap();
/// let bar = bytes.ioread::<u32>().unwrap();
/// assert_eq!(foo, 0xb0b);
/// assert_eq!(bar, 0xbeef);
diff --git a/src/lib.rs b/src/lib.rs
index 2f9ecda..4311485 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -78,7 +78,7 @@
//! let mut bytes = Cursor::new(bytes_);
//!
//! // this will bump the cursor's Seek
-//! let foo = bytes.ioread::<usize>().unwrap();
+//! let foo = bytes.ioread::<u64>().unwrap();
//! // ..ditto
//! let bar = bytes.ioread::<u32>().unwrap();
//! ```
@@ -222,7 +222,10 @@ mod tests {
let bytes: [u8; 2] = [0x7e, 0xef];
let b = &bytes[..];
let byte: u16 = b.pread(0).unwrap();
+ #[cfg(target_endian = "little")]
assert_eq!(0xef7e, byte);
+ #[cfg(target_endian = "big")]
+ assert_eq!(0x7eef, byte);
}
#[test]
diff --git a/tests/api.rs b/tests/api.rs
index e3d8574..942d5af 100644
--- a/tests/api.rs
+++ b/tests/api.rs
@@ -171,13 +171,13 @@ fn lifetime_passthrough() {
#[derive(Default)]
#[repr(packed)]
struct Foo {
- foo: usize,
+ foo: i64,
bar: u32,
}
impl scroll::ctx::FromCtx<scroll::Endian> for Foo {
fn from_ctx(bytes: &[u8], ctx: scroll::Endian) -> Self {
- Foo { foo: bytes.cread_with::<usize>(0, ctx), bar: bytes.cread_with::<u32>(8, ctx) }
+ Foo { foo: bytes.cread_with::<i64>(0, ctx), bar: bytes.cread_with::<u32>(8, ctx) }
}
}
@@ -194,7 +194,7 @@ fn ioread_api() {
use scroll::IOread;
let bytes_ = [0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xef,0xbe,0x00,0x00,];
let mut bytes = Cursor::new(bytes_);
- let foo = bytes.ioread::<usize>().unwrap();
+ let foo = bytes.ioread::<i64>().unwrap();
let bar = bytes.ioread::<u32>().unwrap();
assert_eq!(foo, 1);
assert_eq!(bar, 0xbeef);
@@ -223,7 +223,7 @@ impl scroll::ctx::FromCtx<scroll::Endian> for Bar {
fn cread_api() {
use scroll::Cread;
let bytes = [0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xef,0xbe,0x00,0x00,];
- let foo = bytes.cread::<usize>(0);
+ let foo = bytes.cread::<u64>(0);
let bar = bytes.cread::<u32>(8);
assert_eq!(foo, 1);
assert_eq!(bar, 0xbeef);
@@ -251,9 +251,9 @@ fn cwrite_api() {
use scroll::Cwrite;
use scroll::Cread;
let mut bytes = [0x0; 0x10];
- bytes.cwrite::<usize>(42, 0);
+ bytes.cwrite::<u64>(42, 0);
bytes.cwrite::<u32>(0xdeadbeef, 8);
- assert_eq!(bytes.cread::<usize>(0), 42);
+ assert_eq!(bytes.cread::<u64>(0), 42);
assert_eq!(bytes.cread::<u32>(8), 0xdeadbeef);
}
--
2.15.1

@ -5,22 +5,19 @@
%global crate scroll %global crate scroll
Name: rust-%{crate} Name: rust-%{crate}
Version: 0.7.0 Version: 0.8.0
Release: 1%{?dist} Release: 1%{?dist}
Summary: Powerful, extensible, generic, endian-aware Read/Write traits for byte buffers Summary: Powerful, extensible, generic, endian-aware Read/Write traits for byte buffers
License: MIT License: MIT
URL: https://crates.io/crates/scroll URL: https://crates.io/crates/scroll
Source0: https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{crate}-%{version}.crate Source0: https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{crate}-%{version}.crate
# Initial patched metadata
# * Bump rayon to 0.9, https://github.com/m4b/scroll/commit/2b8ec1ccbf64fc0fa09cced9e9590186bc0c059e
Patch0: scroll-0.7.0-fix-metadata.diff
# https://github.com/m4b/scroll/commit/39e05345064ec1783f58a14ce896d521ef3cfc3a
Patch1: 0001-build-make-tests-more-robust-on-various-architecture.patch
ExclusiveArch: %{rust_arches} ExclusiveArch: %{rust_arches}
BuildRequires: rust-packaging BuildRequires: rust-packaging
# [dependencies]
BuildRequires: (crate(scroll_derive) >= 0.8.0 with crate(scroll_derive) < 0.9.0)
%if %{with check} %if %{with check}
# [dev-dependencies] # [dev-dependencies]
BuildRequires: (crate(byteorder) >= 1.0.0 with crate(byteorder) < 2.0.0) BuildRequires: (crate(byteorder) >= 1.0.0 with crate(byteorder) < 2.0.0)
@ -53,14 +50,7 @@ which use %{crate} from crates.io.
%if %{with check} %if %{with check}
%check %check
# https://github.com/m4b/scroll/issues/20 %cargo_test
# Tests are failing on BE, but because they are written that way.
%cargo_test \
%ifarch ppc64 s390x
|| :
%else
;
%endif
%endif %endif
%files devel %files devel
@ -69,5 +59,8 @@ which use %{crate} from crates.io.
%{cargo_registry}/%{crate}-%{version}/ %{cargo_registry}/%{crate}-%{version}/
%changelog %changelog
* Mon Dec 04 2017 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 0.8.0-1
- Update to 0.8.0
* Fri Dec 01 2017 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 0.7.0-1 * Fri Dec 01 2017 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 0.7.0-1
- Initial package - Initial package

@ -1,11 +0,0 @@
--- scroll-0.7.0/Cargo.toml 1970-01-01T01:00:00+01:00
+++ scroll-0.7.0/Cargo.toml 2017-12-01T15:47:19.695643+01:00
@@ -24,7 +24,7 @@
version = "1.0.0"
[dev-dependencies.rayon]
-version = "0.8.0"
+version = "0.9.0"
[features]
std = []

@ -1 +1 @@
SHA512 (scroll-0.7.0.crate) = 503ac57116128dc560ef48b8928d74aa14c77b3e8d1de189030d8528c7a6294866726fad1490741b775a424ddb5584af60c66983684d8aaa043fd8fc1f36d26b SHA512 (scroll-0.8.0.crate) = 56c2d9e3f7fdd442e49c0eb7ee205eb8af2e110cb781e973fb5244fca45ca546a30861114bdcf985ee7c173d7e72536f250ef40a5ad2f6acbffb4099a89b0f47

Loading…
Cancel
Save