commit_hash stringlengths 40 40 | author stringlengths 1 57 | date timestamp[s]date 2010-07-26 04:45:09 2026-04-14 18:21:10 | message stringlengths 8 1.39M | diff stringlengths 68 51.2k | files_changed int64 1 136 | insertions int64 0 2.35k | deletions int64 0 1.9k |
|---|---|---|---|---|---|---|---|
a2c5dd29d692b5eea4a2fadc860cf9790f3ec0ec | TQ Hirsch | 2016-03-05T13:20:25 | Import libc crate in libc.rs to fix warnings on rust-nightly | diff --git a/src/decoder.rs b/src/decoder.rs
index 565aeda..949e57b 100644
--- a/src/decoder.rs
+++ b/src/decoder.rs
@@ -1,7 +1,7 @@
use std::io::{Error, ErrorKind, Read, Result};
use std::ptr;
use super::liblz4::*;
-use liblz4::libc::size_t;
+use libc::size_t;
const BUFFER_SIZE: usize = 32 * 1024;
diff --git a... | 4 | 5 | 5 |
d28406b63bf5a65352607cb4065df7d08db5c61c | TQ Hirsch | 2016-02-22T22:24:38 | Modified build script to *always* compile the C code with -O3 optimization | diff --git a/src/build.rs b/src/build.rs
index 2a496f1..8c7f9fa 100644
--- a/src/build.rs
+++ b/src/build.rs
@@ -1,10 +1,13 @@
extern crate gcc;
fn main() {
- gcc::compile_library("liblz4.a", &[
- "liblz4/lib/lz4.c",
- "liblz4/lib/lz4frame.c",
- "liblz4/lib/lz4hc.c",
- "liblz4/lib/xxhash.c",
- ]);
+ let mut ... | 1 | 9 | 6 |
0e588b5b4637084c83ee4e288cec2807c4e1529c | Artem V. Navrotskiy | 2016-01-24T21:09:59 | Bump 1.13.131 | diff --git a/Cargo.toml b/Cargo.toml
index 1594807..db96cca 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "lz4"
license = "MIT"
-version = "1.12.131"
+version = "1.13.131"
authors = [ "Artem V. Navrotskiy <bozaro@buzzsoft.ru>" ]
build = "src/build.rs"
description = "Rust LZ4 bindings l... | 1 | 3 | 3 |
8b6a4890cf55b89a798221d9903653ffe5109f9d | Maxime Lenoir | 2015-12-16T15:43:58 | Fix pointer invalidation on Decoder move
When the Decoder is moved, so is Decoder::buf and its address. This
causes pointer invalidation in DecoderContext, leading to errors and
possible segmentation faults. Therefore, Decoder::buf is set to a fixed
address, in exchange for an extra one-shot memory allocation on the
h... | diff --git a/src/decoder.rs b/src/decoder.rs
index 966e17a..565aeda 100644
--- a/src/decoder.rs
+++ b/src/decoder.rs
@@ -12,7 +12,7 @@ struct DecoderContext {
pub struct Decoder<R> {
c: DecoderContext,
r: R,
- buf: [u8; BUFFER_SIZE],
+ buf: Box<[u8]>,
pos: usize,
len: usize,
next: usize,
@@ -26,7 +26,7 @@ im... | 1 | 2 | 2 |
4452a95592fcafcc4e2964d5e46239580843d50a | Artem V. Navrotskiy | 2015-12-05T20:34:17 | Replace empty #[repr(C)] structs with c_void wrappers | diff --git a/src/liblz4.rs b/src/liblz4.rs
index dcf0194..2e8d67e 100644
--- a/src/liblz4.rs
+++ b/src/liblz4.rs
@@ -109,10 +109,10 @@ pub struct LZ4FDecompressOptions
}
#[repr(C)]
-pub struct LZ4StreamEncode;
+pub struct LZ4StreamEncode(c_void);
#[repr(C)]
-pub struct LZ4StreamDecode;
+pub struct LZ4StreamDecod... | 1 | 2 | 2 |
54e97eb07bea68bbbab2302ecb09c881805a8b08 | Artem V. Navrotskiy | 2015-12-05T18:52:09 | More correct smoke test | diff --git a/src/decoder.rs b/src/decoder.rs
index 81375fc..d3dccef 100644
--- a/src/decoder.rs
+++ b/src/decoder.rs
@@ -104,17 +104,18 @@ mod test {
#[test]
fn test_decoder_smoke() {
let mut encoder = EncoderBuilder::new().level(1).build(Vec::new()).unwrap();
- let expected = b"Some data";
+ let mut expected ... | 1 | 5 | 4 |
d33c0303482ae17c39aefef99aca29934b4124d4 | Maxime Lenoir | 2015-11-24T13:03:33 | Fix conflicting import on Rust nightly | diff --git a/src/decoder.rs b/src/decoder.rs
index 89ed631..81375fc 100644
--- a/src/decoder.rs
+++ b/src/decoder.rs
@@ -1,11 +1,8 @@
-extern crate libc;
-
use std::io::Read;
use std::io::Result;
use std::ptr;
use super::liblz4::*;
-
-use self::libc::size_t;
+use liblz4::libc::size_t;
const BUFFER_SIZE: usize = ... | 2 | 3 | 9 |
f517177abed26da5e09a1948f283c485556b8b23 | Brian Vincent | 2015-09-27T19:57:12 | Don't try to fill up the entire buffer on a read.
An LZ4 frame is designed so that partial blocks can be "flushed" by
the encoder at any time. A frame can be a long term stream sent over
a network connection. The decoder needs to be sure that it only calls
the underlying read once at a time, when necessary, and be a... | diff --git a/src/decoder.rs b/src/decoder.rs
index 6b3f4ca..89ed631 100644
--- a/src/decoder.rs
+++ b/src/decoder.rs
@@ -41,12 +41,12 @@ impl<R: Read> Decoder<R> {
impl<R: Read> Read for Decoder<R> {
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
{
- if self.eof
+ if self.eof || buf.len() == 0
{
retu... | 1 | 2 | 2 |
dc1f332af143c1a917a161e037de0f717118f7d3 | Brian Vincent | 2015-09-14T03:21:32 | Fix incorrect break that could cause reading after a frame ends | diff --git a/src/decoder.rs b/src/decoder.rs
index 81c4a74..6b3f4ca 100644
--- a/src/decoder.rs
+++ b/src/decoder.rs
@@ -66,7 +66,7 @@ impl<R: Read> Read for Decoder<R> {
dst_offset += dst_size as usize;
if len == 0 {
self.eof = true;
- break;
+ return Ok(dst_offset);
}
}
} | 1 | 1 | 1 |
1ecb475fb253ed676c32f497e52d9b4ccacb82ec | Elaine Nemo | 2015-08-29T16:25:28 | Show liblz4 submodule since it's not fully reexported | diff --git a/src/lib.rs b/src/lib.rs
index e5dd77d..074baed 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,4 +1,4 @@
-mod liblz4;
+pub mod liblz4;
mod decoder;
mod encoder; | 1 | 1 | 1 |
e1d8ba101d3b48b8b33337c42c612b2ee13929dc | Elaine Nemo | 2015-08-29T16:03:04 | Bump version | diff --git a/Cargo.toml b/Cargo.toml
index 69faec0..3081d37 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "lz4"
license = "MIT"
-version = "1.7.129"
+version = "1.7.130"
authors = [ "Artem V. Navrotskiy <bozaro@buzzsoft.ru>" ]
build = "src/build.rs"
description = "Rust LZ4 bindings lib... | 1 | 1 | 1 |
65c2dd7257cb4ff4f0849e86b535064cddc4fd4e | Elaine Nemo | 2015-08-29T16:02:44 | Hide modules from the public API, only the re-exports should be used | diff --git a/src/lib.rs b/src/lib.rs
index 871ba7e..e5dd77d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,6 +1,6 @@
-pub mod liblz4;
-pub mod decoder;
-pub mod encoder;
+mod liblz4;
+mod decoder;
+mod encoder;
pub use decoder::Decoder;
pub use encoder::Encoder; | 1 | 3 | 3 |
b5956767ef2f55f2d88f89b6a33a033a594a7118 | Tomoki Aonuma | 2015-05-20T09:43:32 | Fix typo in Cargo.toml | diff --git a/Cargo.toml b/Cargo.toml
index b8636a5..69faec0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,7 +4,7 @@ license = "MIT"
version = "1.7.129"
authors = [ "Artem V. Navrotskiy <bozaro@buzzsoft.ru>" ]
build = "src/build.rs"
-description = "Rust LZ4 bindins library."
+description = "Rust LZ4 bindings library... | 1 | 1 | 1 |
a45f9d276643344ba88e105fbc84c516cbdee29b | Artem V. Navrotskiy | 2015-05-21T10:20:55 | Remove libc type publishing | diff --git a/src/decoder.rs b/src/decoder.rs
index 7c21e0b..9fdcf2c 100644
--- a/src/decoder.rs
+++ b/src/decoder.rs
@@ -1,8 +1,12 @@
+extern crate libc;
+
use std::io::Read;
use std::io::Result;
use std::ptr;
use super::liblz4::*;
+use self::libc::size_t;
+
const BUFFER_SIZE: usize = 32 * 1024;
struct Decode... | 3 | 9 | 2 |
2bf4d021c5a6628cfe318c93950583b96ef13ff4 | Artem V. Navrotskiy | 2015-05-20T06:40:07 | Version: 1.6.129 | diff --git a/Cargo.toml b/Cargo.toml
index 5c06095..c191edc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "lz4"
license = "MIT"
-version = "1.5.129"
+version = "1.6.129"
authors = [ "Artem V. Navrotskiy <bozaro@buzzsoft.ru>" ]
build = "src/build.rs"
description = "Rust LZ4 bindins libr... | 1 | 1 | 1 |
ed6430a7df990518fa7f81905411a022026d24ae | Artem V. Navrotskiy | 2015-05-05T20:52:52 | Add test | diff --git a/Cargo.toml b/Cargo.toml
index 1dbd04b..8c6acb9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "lz4"
license = "MIT"
-version = "1.4.128"
+version = "1.5.128"
authors = [ "Artem V. Navrotskiy <bozaro@buzzsoft.ru>" ]
build = "src/build.rs"
description = "Rust LZ4 bindins libr... | 3 | 52 | 21 |
f2bb2d6b07d0202a76371928e00999e7b449cc39 | Artem V. Navrotskiy | 2015-04-11T13:12:24 | Remove compilation warnings | diff --git a/Cargo.toml b/Cargo.toml
index b607730..aa4fd2f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,8 +7,12 @@ build = "src/build.rs"
description = "Rust LZ4 bindins library."
repository = "https://github.com/bozaro/lz4-rs"
-[dependencies]
-libc = "*"
+[[bin]]
+name = "lz4"
+test = false
+
+[dependencies]
... | 1 | 6 | 2 |
020503b14c68283fa90d57ed2d9085f14c17d398 | Artem V. Navrotskiy | 2015-04-11T12:00:01 | Rustup: 1.0.0-beta | diff --git a/Cargo.toml b/Cargo.toml
index 5168500..b607730 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,11 +1,14 @@
[package]
name = "lz4"
license = "MIT"
-version = "1.3.127"
+version = "1.4.127"
authors = [ "Artem V. Navrotskiy <bozaro@buzzsoft.ru>" ]
build = "src/build.rs"
description = "Rust LZ4 bindins li... | 2 | 4 | 3 |
769baef7c3fa776321b7935ad3116df7ac75062c | a.navrotskiy | 2015-04-03T08:32:22 | More simple error formating | diff --git a/src/lib.rs b/src/lib.rs
index 41f93f0..497dfe3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,5 +1,4 @@
#![feature(libc)]
-#![feature(debug_builders)]
pub mod liblz4;
pub mod decoder;
diff --git a/src/liblz4.rs b/src/liblz4.rs
index da22594..6cb7906 100644
--- a/src/liblz4.rs
+++ b/src/liblz4.rs
@@ -2... | 2 | 2 | 3 |
8939972d768b93c4137b58dfe096691975fa0227 | Artem V. Navrotskiy | 2015-04-02T21:11:10 | Improve error reporting | diff --git a/src/lib.rs b/src/lib.rs
index 497dfe3..41f93f0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,4 +1,5 @@
#![feature(libc)]
+#![feature(debug_builders)]
pub mod liblz4;
pub mod decoder;
diff --git a/src/liblz4.rs b/src/liblz4.rs
index 2ad3be1..da22594 100644
--- a/src/liblz4.rs
+++ b/src/liblz4.rs
@@ -2... | 2 | 2 | 1 |
3f88edb664478c6f5e14a27fbf5a842af51d48ff | Artem V. Navrotskiy | 2015-04-02T20:44:56 | Compilation fix | diff --git a/Cargo.toml b/Cargo.toml
index 51f0dea..5168500 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "lz4"
license = "MIT"
-version = "1.2.127"
+version = "1.3.127"
authors = [ "Artem V. Navrotskiy <bozaro@buzzsoft.ru>" ]
build = "src/build.rs"
description = "Rust LZ4 bindins libr... | 3 | 23 | 3 |
27d6cb301fbc5369bab68db94453d3776aece5e7 | a.navrotskiy | 2015-03-20T08:02:24 | Compilation fix | diff --git a/Cargo.toml b/Cargo.toml
index fa757b0..51f0dea 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "lz4"
license = "MIT"
-version = "1.1.127"
+version = "1.2.127"
authors = [ "Artem V. Navrotskiy <bozaro@buzzsoft.ru>" ]
build = "src/build.rs"
description = "Rust LZ4 bindins libr... | 3 | 3 | 3 |
4b90a98b211284732d48c2958340b9c945b5adb3 | Artem V. Navrotskiy | 2015-03-17T04:22:59 | Remove deprecated API: old_io -> io | diff --git a/Cargo.toml b/Cargo.toml
index 4311c32..fa757b0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,11 +1,11 @@
[package]
name = "lz4"
license = "MIT"
-version = "1.0.127"
+version = "1.1.127"
authors = [ "Artem V. Navrotskiy <bozaro@buzzsoft.ru>" ]
build = "src/build.rs"
description = "Rust LZ4 bindins li... | 6 | 49 | 68 |
36d5fe663cf90cc9dac4479c7a01093ca3956f72 | a.navrotskiy | 2015-03-02T07:26:26 | Rename cargo | diff --git a/Cargo.toml b/Cargo.toml
index 56d0004..4311c32 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,5 +1,5 @@
[package]
-name = "lz4-rs"
+name = "lz4"
license = "MIT"
version = "1.0.127"
authors = [ "Artem V. Navrotskiy <bozaro@buzzsoft.ru>" ]
diff --git a/src/bin/lz4.rs b/src/bin/lz4.rs
index 614269b..e8163... | 3 | 3 | 3 |
6a310c29e9281433e75aa0f7f9b0626fc7a474f4 | Artem V. Navrotskiy | 2015-03-02T04:07:14 | Update for cargo | diff --git a/Cargo.toml b/Cargo.toml
index dca08e5..56d0004 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,8 +2,10 @@
name = "lz4-rs"
license = "MIT"
version = "1.0.127"
-authors = [ "Artem V. Navrotskiy <bozaro@users.noreply.github.com>" ]
+authors = [ "Artem V. Navrotskiy <bozaro@buzzsoft.ru>" ]
build = "src/buil... | 3 | 5 | 3 |
05cea1788f0a888809e6c9c29f6330b59888f3dd | Artem V. Navrotskiy | 2015-03-01T08:19:34 | Add example of usage | diff --git a/src/bin/lz4.rs b/src/bin/lz4.rs
new file mode 100644
index 0000000..614269b
--- /dev/null
+++ b/src/bin/lz4.rs
@@ -0,0 +1,67 @@
+#![feature(old_io)]
+#![feature(old_path)]
+#![feature(os)]
+extern crate "lz4-rs" as lz4;
+
+use std::os;
+use std::old_path::Path;
+use std::old_io::fs::File;
+use std::old_io:... | 4 | 118 | 29 |
4cd13c1b51b9ff746e7a2af35d97f9ab5021874b | Artem V. Navrotskiy | 2015-02-28T20:40:39 | Add LZ4 decompression Reader | diff --git a/src/decoder.rs b/src/decoder.rs
new file mode 100644
index 0000000..1cbcca3
--- /dev/null
+++ b/src/decoder.rs
@@ -0,0 +1,99 @@
+use std::old_io::Reader;
+use std::old_io::IoResult;
+use std::old_io::IoErrorKind;
+use std::ptr;
+use super::liblz4::*;
+
+const BUFFER_SIZE: usize = 32 * 1024;
+
+pub struct D... | 4 | 182 | 10 |
3d6174baed25281a9f721aff4bb59858dfa87c2e | Artem V. Navrotskiy | 2015-02-28T18:02:12 | Add LZ4 compression Writer | diff --git a/src/encoder.rs b/src/encoder.rs
new file mode 100644
index 0000000..9635cc9
--- /dev/null
+++ b/src/encoder.rs
@@ -0,0 +1,134 @@
+use std::old_io::Writer;
+use std::old_io::IoResult;
+use std::cmp;
+use std::ptr;
+use super::liblz4::*;
+
+const BUFFER_SIZE: usize = 32 * 1024;
+
+pub struct EncoderContext {... | 3 | 299 | 0 |
21d05808ffd50db8415f1583a99bb8ee5e074d69 | Artem V. Navrotskiy | 2015-02-28T09:25:58 | Add mapping for native LZ4 functions | diff --git a/src/bin/version.rs b/src/bin/version.rs
index 96b0779..fb5eef2 100644
--- a/src/bin/version.rs
+++ b/src/bin/version.rs
@@ -1,8 +1,3 @@
-#![feature(core)]
-#![feature(io)]
-#![feature(path)]
-#![feature(os)]
-#![feature(std_misc)]
extern crate "lz4-rs" as lz4;
use lz4::liblz4::*;
diff --git a/src/liblz... | 2 | 36 | 14 |
84f8da355374aa8440682ce0f328ac4b97920947 | Artem V. Navrotskiy | 2015-02-28T08:42:31 | Add liblz4.a compilation with Cargo | diff --git a/Cargo.toml b/Cargo.toml
index f3f375e..dca08e5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,6 +3,7 @@ name = "lz4-rs"
license = "MIT"
version = "1.0.127"
authors = [ "Artem V. Navrotskiy <bozaro@users.noreply.github.com>" ]
+build = "src/build.rs"
-[lib]
-name = "lz4-rs"
+[build-dependencies]
+gcc =... | 4 | 16 | 4 |
69aa7a28088e5e1f0cc4543be47b61775baf6764 | Artem V. Navrotskiy | 2015-02-27T20:47:13 | Begin binding | diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 0000000..f3f375e
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "lz4-rs"
+license = "MIT"
+version = "1.0.127"
+authors = [ "Artem V. Navrotskiy <bozaro@users.noreply.github.com>" ]
+
+[lib]
+name = "lz4-rs"
diff --git a/src/bin/version.... | 4 | 34 | 0 |
18f32ca3a41c9823138e782752bc439e99ef7ec8 | Jonathan Behrens | 2024-04-02T03:10:06 | float: use safe code for floating point endian conversion
This makes use of the 'from_bits' routines. | diff --git a/src/lib.rs b/src/lib.rs
index a32a4a1..d4af68f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2054,10 +2054,7 @@ impl ByteOrder for BigEndian {
fn from_slice_f32(numbers: &mut [f32]) {
if cfg!(target_endian = "little") {
for n in numbers {
- unsafe {
- ... | 1 | 4 | 16 |
2e17045ca2580719b2df78973901b56eb8a86f49 | Adam Ciarciński | 2023-10-29T21:02:49 | Simplify pack_size() and pack_size128() | diff --git a/src/lib.rs b/src/lib.rs
index cfd53c3..a32a4a1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -110,60 +110,12 @@ fn unextend_sign128(val: i128, nbytes: usize) -> u128 {
#[inline]
fn pack_size(n: u64) -> usize {
- if n < 1 << 8 {
- 1
- } else if n < 1 << 16 {
- 2
- } else if n < 1 <<... | 1 | 4 | 52 |
52cc70cf458517ef70b2e665079d82dfbe77f4fd | Lukasz Anforowicz | 2023-08-29T19:30:07 | safety: verify alignment requirements of floats vs ints
Fixes #194, Closes #195 | diff --git a/src/lib.rs b/src/lib.rs
index bcb53f3..cfd53c3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -74,7 +74,8 @@ cases.
#![cfg_attr(miri, allow(dead_code, unused_macros))]
use core::{
- convert::TryInto, fmt::Debug, hash::Hash, ptr::copy_nonoverlapping, slice,
+ convert::TryInto, fmt::Debug, hash::Hash,... | 1 | 4 | 1 |
c0b6678e8d9da8365fcf68a41d0dc228304ce079 | Michal Nazarewicz | 2023-08-21T01:11:48 | impl: remove unsafe code from read_uint and read_uint128 methods
Rewrite read_uint and read_uint128 methods such that they no longer
use unsafe code. Rather than casting pointers and doing unsafe
copies, declare output byte buffer for the read number and use
from_xx_bytes method to convert those read bytes to a numbe... | diff --git a/src/lib.rs b/src/lib.rs
index 4868091..bcb53f3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1955,32 +1955,20 @@ impl ByteOrder for BigEndian {
#[inline]
fn read_uint(buf: &[u8], nbytes: usize) -> u64 {
- assert!(1 <= nbytes && nbytes <= 8 && nbytes <= buf.len());
- let mut out = 0... | 1 | 18 | 36 |
1e2d8b090a4d6d6afaded73485a00b8ea8cdee10 | Michal Nazarewicz | 2023-08-21T00:36:30 | impl: eliminate unsafe_write_num_bytes
unsafe_write_num_bytes macro can be replaced by a perfectly safe code
which uses `n::to_xx_bytes()` to convert given number to desired
representation and `buf[..N].copy_from_slice(...)` which writes that
into the buffer.
Closes #193 | diff --git a/src/lib.rs b/src/lib.rs
index ba20145..4868091 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1898,23 +1898,6 @@ pub type NativeEndian = LittleEndian;
#[cfg(target_endian = "big")]
pub type NativeEndian = BigEndian;
-/// Copies $size bytes from a number $n to a &mut [u8] $dst. $ty represents the
-/// num... | 1 | 8 | 25 |
368cb55c3d572a2f25250dce1c8e279d43f65a8e | Michal Nazarewicz | 2023-08-21T02:08:59 | impl: refactor write_slice macro slightly
Firstly, get rid of $size argument. The size can be determined from
$ty so there’s no need to pass it as a separate argument. Secondly,
change it to use to_xx_bytes methods instead of Self::write_uxx so
that it resembles read_slice. | diff --git a/src/lib.rs b/src/lib.rs
index 49f3767..ba20145 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1932,13 +1932,19 @@ macro_rules! read_slice {
}};
}
+/// Copies a &[$ty] $src into a &mut [u8] $dst for the endianness given by
+/// $from_bytes (must be either from_be_bytes or from_le_bytes).
+///
+/// Pan... | 1 | 20 | 14 |
c01f0fe987c952373bc558e1e15ecb6070af4f1a | Michal Nazarewicz | 2023-08-21T02:05:08 | impl: eliminate special case checking target_endian
The compiler is smart enough that it notices when endianess conversion
is not necessary and it simplifies copying with a conversion into
plain memcpy. This means there’s no need to check target_endian and
use unsafe_write_slice_native macro. | diff --git a/src/lib.rs b/src/lib.rs
index 4f954db..49f3767 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1932,27 +1932,6 @@ macro_rules! read_slice {
}};
}
-/// Copies a &[$ty] $src into a &mut [u8] $dst, where $ty must be a numeric
-/// type. This panics if size_of::<$ty>() * $src.len() != $dst.len().
-///
-//... | 1 | 8 | 61 |
3409ee1f7a0fa7d90c7c9eb784b6b4d53cbba388 | Michal Nazarewicz | 2023-08-21T01:03:45 | perf: convert endianess while reading slice in a single pass
Replace unsafe_read_slice macro which first copies data to destination
buffer and then swaps endianess if necessary with a read_slice macro
which does the swapping in a single pass while the data is read.
This is done with `[T]:chunks_exact` which splits so... | diff --git a/src/lib.rs b/src/lib.rs
index 449e82d..4f954db 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1915,25 +1915,19 @@ macro_rules! unsafe_write_num_bytes {
}};
}
-/// Copies a &[u8] $src into a &mut [<numeric>] $dst for the endianness given
-/// by $which (must be either to_be or to_le).
+/// Copies a &[... | 1 | 20 | 26 |
8d02d506317322c14f5f8c02ea2729c0a832c7d0 | Michal Nazarewicz | 2022-12-05T15:54:27 | bench: add read/write into benchmarks for u16 and i64
Add read/write into benchmark for u16 to test how the code behaves if
the type is smaller than the native register size and for i64 to test
that there’s nothing weird going on with signedness conversion. | diff --git a/benches/bench.rs b/benches/bench.rs
index bb00422..963251c 100644
--- a/benches/bench.rs
+++ b/benches/bench.rs
@@ -321,4 +321,6 @@ macro_rules! bench_slice {
};
}
+bench_slice!(slice_u16, u16, read_u16_into, write_u16_into);
bench_slice!(slice_u64, u64, read_u64_into, write_u64_into);
+bench_slic... | 1 | 2 | 0 |
83f9eeaa7fd30bf1249e732661a23607ba7be8ce | Jim Turner | 2021-03-10T12:33:22 | impl: change as_ptr to as_mut_ptr to fix Miri error
Before, the example in the docs for `ByteOrder::from_slice_i32` caused
Miri to error with the message, "error: Undefined Behavior: trying to
reborrow for Unique at alloc1389, but parent tag <untagged> does not
have an appropriate item in the borrow stack". Now it ... | diff --git a/src/lib.rs b/src/lib.rs
index 5d0f3a2..cc37cca 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1692,7 +1692,7 @@ pub trait ByteOrder:
#[inline]
fn from_slice_i16(src: &mut [i16]) {
let src = unsafe {
- slice::from_raw_parts_mut(src.as_ptr() as *mut u16, src.len())
+ sl... | 1 | 4 | 4 |
5d9d0386488d0763954f14a5cb02b1c0afccbdcb | Andrew Gallant | 2021-02-24T16:25:37 | impl: prefix unsafe macros with 'unsafe_'
If these could be defined as functions, then we would have considered
them to be unsound. Since there is no such thing as an "unsafe macro" in
Rust, we adopt a convention that such a macro start with 'unsafe_'.
There are no changes in the safety properties of the implementati... | diff --git a/src/io.rs b/src/io.rs
index ac41ff7..dfad2ca 100644
--- a/src/io.rs
+++ b/src/io.rs
@@ -1582,7 +1582,8 @@ impl<W: io::Write + ?Sized> WriteBytesExt for W {}
/// representation.
///
/// This function is wildly unsafe because it permits arbitrary modification of
-/// the binary representation of any `Copy... | 2 | 52 | 37 |
54ca336ec2b11a3036eb6a5951738b1a72692f12 | Andrew Gallant | 2021-01-08T16:47:25 | crates.io: no_std -> no-std
Apparently this got changed? Or maybe it was never correct. | diff --git a/Cargo.toml b/Cargo.toml
index f0f0670..14760ad 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,7 +7,7 @@ documentation = "https://docs.rs/byteorder"
homepage = "https://github.com/BurntSushi/byteorder"
repository = "https://github.com/BurntSushi/byteorder"
readme = "README.md"
-categories = ["encoding", ... | 1 | 1 | 1 |
0ead1057d4d1ea59ad9c8e5bc35514646ef8fb83 | Andrew Gallant | 2021-01-08T16:45:21 | impl: fix read implementations
When moving to the std array->int APIs, we passed the slice in as-is.
But the std APIs (via TryInto) require a slice that is exactly the size
of the array, where as the byteorder APIs do not. So we sub-slice to
meet that criterion.
Fixes #173 | diff --git a/src/lib.rs b/src/lib.rs
index 1f2c9cc..d56574d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1956,22 +1956,22 @@ macro_rules! write_slice {
impl ByteOrder for BigEndian {
#[inline]
fn read_u16(buf: &[u8]) -> u16 {
- u16::from_be_bytes(buf.try_into().unwrap())
+ u16::from_be_bytes(bu... | 1 | 49 | 8 |
37daff6927988a85bb00eb6b1d83564d81279505 | Andrew Gallant | 2021-01-06T20:04:45 | impl: use std endian conversion routines
Interestingly, I could really only find a way to use the array->int
conversions. We could use the int->array conversions, but it ends up
being pretty circuitous. | diff --git a/src/lib.rs b/src/lib.rs
index 24e36e9..1f2c9cc 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -70,7 +70,9 @@ cases.
#![deny(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]
-use core::{fmt::Debug, hash::Hash, ptr::copy_nonoverlapping, slice};
+use core::{
+ convert::TryInto, fmt::Debug, hash::... | 1 | 15 | 31 |
8061190ab681813d9475b6298d609f5d1b42434f | Andrew Gallant | 2021-01-06T14:18:24 | deps: update to quickcheck 0.9 and rand 0.7 | diff --git a/Cargo.toml b/Cargo.toml
index 7cee8d8..0e87eb6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -18,8 +18,8 @@ name = "byteorder"
bench = false
[dev-dependencies]
-quickcheck = { version = "0.8", default-features = false }
-rand = "0.6"
+quickcheck = { version = "0.9.2", default-features = false }
+rand = "... | 1 | 2 | 2 |
6dac6ebe13fc3ebff5e6a26e8ce60873cf0969ef | Benoît du Garreau | 2020-03-11T00:09:54 | crates.io: add no_std in categories | diff --git a/Cargo.toml b/Cargo.toml
index c890e51..7cee8d8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,7 +7,7 @@ documentation = "https://docs.rs/byteorder"
homepage = "https://github.com/BurntSushi/byteorder"
repository = "https://github.com/BurntSushi/byteorder"
readme = "README.md"
-categories = ["encoding", ... | 1 | 1 | 1 |
601408783c7c29a59bc930d2e23e4efc563eeae4 | Andrew Gallant | 2020-02-07T13:17:19 | tidy: squash deprecation warnings for try! macro
We should bump our MSRV soon, but until we do, there's no point in
having these plastered everywhere. | diff --git a/build.rs b/build.rs
index 002135b..320e894 100644
--- a/build.rs
+++ b/build.rs
@@ -1,3 +1,6 @@
+// For the 'try!' macro, until we bump MSRV past 1.12.
+#![allow(deprecated)]
+
use std::env;
use std::ffi::OsString;
use std::io::{self, Write};
diff --git a/src/lib.rs b/src/lib.rs
index 2c3492e..5423ed1 1... | 2 | 6 | 0 |
1f8d40dd16b4ad136be8acabfec6eac69fff1af6 | Andrew Champion | 2020-02-07T13:14:51 | api: add write_i8_into to ByteOrder trait
Similar to #147, this method is useful for completeness because it
prevents users having to write their own unsafe code or loop over all
bytes calling write_i8 to efficiently write an i8 slice into a u8
buffer.
PR #156 | diff --git a/src/lib.rs b/src/lib.rs
index 9336f64..2c3492e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1411,6 +1411,40 @@ pub trait ByteOrder
#[cfg(byteorder_i128)]
fn write_u128_into(src: &[u128], dst: &mut [u8]);
+ /// Writes signed 8 bit integers from `src` into `dst`.
+ ///
+ /// Note that si... | 1 | 34 | 0 |
4d0764c53abc619aede988f60dad2693d1e1e9f3 | Andrew Gallant | 2020-01-10T11:43:08 | tidy: code touchups
I believe these were found by clippy. | diff --git a/src/lib.rs b/src/lib.rs
index 90bda94..9336f64 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2461,7 +2461,7 @@ mod test {
fn prop(n: $ty_int) -> bool {
let mut buf = [0; 16];
BigEndian::$write(&mut buf, n.clone(), $bytes);
- ... | 1 | 7 | 7 |
15e9281a902af1d9b96016200b7bff090e546532 | Andrew Gallant | 2020-01-10T11:41:30 | safety: ensure that we dereference an aligned pointer
Previously, we were copying data to a `[u8; 8]` and then dereferencing a
pointer to `[u8; 8]` as if it were a `u64`. However, this is actually
undefined behavior since `[u8; 8]` has a smaller alignment than `u64`.
To fix this, we start with a `u64` such that we ar... | diff --git a/src/lib.rs b/src/lib.rs
index db4d24d..90bda94 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1979,26 +1979,26 @@ impl ByteOrder for BigEndian {
#[inline]
fn read_uint(buf: &[u8], nbytes: usize) -> u64 {
assert!(1 <= nbytes && nbytes <= 8 && nbytes <= buf.len());
- let mut out = [0u... | 1 | 12 | 12 |
81889427848a53b922c2bffb7ae0683273aa3d6f | Jim Turner | 2019-06-09T13:40:35 | io: add read_i8_into to ReadBytesExt
The `read_i8_into` method is useful for client code
that wants to avoid `unsafe`.
PR #147 | diff --git a/src/io.rs b/src/io.rs
index bc49a1c..ed6a848 100644
--- a/src/io.rs
+++ b/src/io.rs
@@ -685,6 +685,42 @@ pub trait ReadBytesExt: io::Read {
Ok(())
}
+ /// Reads a sequence of signed 8 bit integers from the underlying reader.
+ ///
+ /// The given buffer is either filled completely ... | 1 | 36 | 0 |
43c437747c91d17bfc866f0a03a107e8430e6c70 | Guillaume Gomez | 2019-05-01T14:53:01 | test: check examples in README
PR #146 | diff --git a/Cargo.toml b/Cargo.toml
index 3475bb0..17272e1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -20,6 +20,7 @@ bench = false
[dev-dependencies]
quickcheck = { version = "0.8", default-features = false }
rand = "0.6"
+doc-comment = "0.3"
[features]
default = ["std"]
diff --git a/src/lib.rs b/src/lib.rs
in... | 2 | 8 | 0 |
c25f0f9db85c3de547053db8a36e208930c836e0 | Andrew Gallant | 2019-03-04T21:20:42 | doc: fix overflowing literals in doc tests
These were likely a result of copy & pasting example code. There is
actually an overflowing literal lint that would normally catch this, but
doc tests do not need to output lint warnings by default.
Rust 2018 made overflowing literals deny-by-default, and Rust 2015 just
rece... | diff --git a/src/lib.rs b/src/lib.rs
index 497e914..0274d74 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -200,8 +200,8 @@ mod private {
/// use byteorder::{ByteOrder, BigEndian};
///
/// let mut buf = [0; 2];
-/// BigEndian::write_i16(&mut buf, -50_000);
-/// assert_eq!(-50_000, BigEndian::read_i16(&buf));
+/// BigEn... | 1 | 13 | 13 |
802bc11cd2a0a7a8bfdad5749baf58683ea0bcf3 | Trevor Spiteri | 2019-01-21T22:46:25 | build: add back support for Rust 1.12
In older versions of Rust, the build.rs file is not auto-detected, so we
add it to the Cargo.toml. Moreover, the existing build.rs was not
compatible with older Rust versions because of the use of eprintln! and
short-hand struct initialization. We fix that.
Closes #140, Closes #1... | diff --git a/Cargo.toml b/Cargo.toml
index 8d612f6..5a1f1d8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,6 +11,7 @@ categories = ["encoding", "parsing"]
keywords = ["byte", "endian", "big-endian", "little-endian", "binary"]
license = "Unlicense OR MIT"
exclude = ["/ci/*"]
+build = "build.rs"
[lib]
name = "byt... | 2 | 11 | 5 |
a7dcbd8ce7921d789f0c11c50f90e6eab351081d | Andrew Gallant | 2019-01-19T13:36:33 | api: deprecate ByteOrder::read_{f32,f64}_into_unchecked
I had intended to deprecate these in the 1.2 release, along with the
corresponding methods on ReadBytesExt/WriteBytesExt, but missed them. | diff --git a/src/lib.rs b/src/lib.rs
index 54ce786..497e914 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1201,17 +1201,48 @@ pub trait ByteOrder
/// LittleEndian::write_f32_into(&numbers_given, &mut bytes);
///
/// let mut numbers_got = [0.0; 4];
- /// LittleEndian::read_f32_into_unchecked(&bytes, &mu... | 1 | 71 | 8 |
7dab8dd000f6b872ac362051858f9210a9af8b89 | Andrew Gallant | 2019-01-19T13:36:25 | doc: remove overflowing literals
It was a copy & paste error.
Fixes #123 | diff --git a/src/lib.rs b/src/lib.rs
index 63d5170..54ce786 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1197,7 +1197,7 @@ pub trait ByteOrder
/// use byteorder::{ByteOrder, LittleEndian};
///
/// let mut bytes = [0; 16];
- /// let numbers_given = [1.0, 2.0, 31.312e311, -11.32e91];
+ /// let number... | 1 | 2 | 2 |
5b3ffeeed2d04ec5051336ea2c6e6d36abc94581 | Andrew Gallant | 2019-01-19T13:25:30 | i128: enable support for 128-bit integers automatically
This adds a build.rs to byteorder that will set a conditional compilation
flag automatically if the current Rust compiler supports 128-bit integers.
This makes the i128 feature itself a no-op. We continue to allow the
feature to be supplied for backwards compati... | diff --git a/Cargo.toml b/Cargo.toml
index 5ace9d8..f258ee2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,6 +23,10 @@ rand = "0.6"
[features]
default = ["std"]
std = []
+
+# This feature is no longer used and is DEPRECATED. This crate now
+# automatically enables i128 support for Rust compilers that support it. Th... | 5 | 274 | 186 |
ce4489fc040716d3748c4a4e9705f6416e2abd70 | Andrew Gallant | 2019-01-19T13:16:32 | deps: update quickcheck and rand
Fixes #127 | diff --git a/Cargo.toml b/Cargo.toml
index e52ee10..5ace9d8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,8 +17,8 @@ name = "byteorder"
bench = false
[dev-dependencies]
-quickcheck = { version = "0.7", default-features = false }
-rand = "0.5"
+quickcheck = { version = "0.8", default-features = false }
+rand = "0.... | 2 | 3 | 3 |
ae5be95de68cca25555015d504060f887ae5187c | Igor Gnatenko | 2018-10-26T17:45:01 | ci: exclude CI files
PR #133 | diff --git a/Cargo.toml b/Cargo.toml
index b9ff700..adcf19b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,6 +10,7 @@ readme = "README.md"
categories = ["encoding", "parsing"]
keywords = ["byte", "endian", "big-endian", "little-endian", "binary"]
license = "Unlicense OR MIT"
+exclude = ["/ci/*"]
[lib]
name = "b... | 1 | 1 | 0 |
be4e53a15eae70f0b60a5b48eda104021fccbc99 | Artyom Pavlov | 2018-10-08T15:27:17 | cargo: use OR in the license field
PR #131 | diff --git a/Cargo.toml b/Cargo.toml
index 1ada583..b9ff700 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,7 +9,7 @@ repository = "https://github.com/BurntSushi/byteorder"
readme = "README.md"
categories = ["encoding", "parsing"]
keywords = ["byte", "endian", "big-endian", "little-endian", "binary"]
-license = "Unli... | 1 | 1 | 1 |
b22bff6edfc55d2a53467d4fe3c73d5127877742 | Andrew Gallant | 2018-08-25T14:34:14 | deps: more updates in test code for rand 0.4 -> 0.5 | diff --git a/benches/bench.rs b/benches/bench.rs
index 8233a07..3982476 100644
--- a/benches/bench.rs
+++ b/benches/bench.rs
@@ -261,12 +261,15 @@ macro_rules! bench_slice {
use byteorder::{ByteOrder, BigEndian, LittleEndian};
use rand::{self, Rng};
+ use rand::distributions;
... | 2 | 18 | 9 |
1ae9a1b55b92f70d1404f41ba48e7109b4a07f53 | Andrew Gallant | 2018-08-25T14:18:41 | deps: update to quickcheck 0.7
Our dev-dependencies already pushed us over the minimum Rust version
supported (1.12.0), so we continue with the status quo of only testing
on stable/beta/nightly, but ensure that we continue to build on Rust
1.12.0. | diff --git a/Cargo.toml b/Cargo.toml
index ea66751..3afd004 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,5 @@
[package]
name = "byteorder"
-# NB: When modifying, also modify html_root_url in lib.rs
version = "1.2.4" #:version
authors = ["Andrew Gallant <jamslam@gmail.com>"]
description = "Library for readi... | 2 | 2 | 4 |
ed8985cb02ae61f0cdbf3e3557028017ffaa4be6 | fpgaminer | 2018-07-30T23:07:13 | byteorder: fix typos in ReadBytesExt docs
Closes #129 | diff --git a/src/io.rs b/src/io.rs
index 76256a1..74cf9dd 100644
--- a/src/io.rs
+++ b/src/io.rs
@@ -43,7 +43,7 @@ pub trait ReadBytesExt: io::Read {
///
/// ```rust
/// use std::io::Cursor;
- /// use byteorder::{BigEndian, ReadBytesExt};
+ /// use byteorder::ReadBytesExt;
///
/// let mut... | 1 | 3 | 3 |
3c69cfd0f8e9e85984d5589d2919cec6facf238d | fpgaminer | 2018-07-30T23:00:18 | byteorder: add doc tests for WriteBytesExt methods
Closes #129 | diff --git a/src/io.rs b/src/io.rs
index 546907e..76256a1 100644
--- a/src/io.rs
+++ b/src/io.rs
@@ -1056,6 +1056,19 @@ pub trait WriteBytesExt: io::Write {
/// This method returns the same errors as [`Write::write_all`].
///
/// [`Write::write_all`]: https://doc.rust-lang.org/std/io/trait.Write.html#met... | 1 | 216 | 0 |
5bdd2715f3ba81e3d534e0227483525600778f1d | fpgaminer | 2018-07-30T20:33:42 | byteorder: add {u,i}48 methods
PR #128 | diff --git a/src/io.rs b/src/io.rs
index 9a66e79..546907e 100644
--- a/src/io.rs
+++ b/src/io.rs
@@ -244,6 +244,58 @@ pub trait ReadBytesExt: io::Read {
Ok(T::read_i32(&buf))
}
+ /// Reads an unsigned 48 bit integer from the underlying reader.
+ ///
+ /// # Errors
+ ///
+ /// This method ... | 2 | 170 | 0 |
965103be61f7e1264c66a047029a0b026e113b47 | Lee Bousfield | 2018-05-12T22:57:52 | i128: get rid of i128 Rust feature
We no longer need to enable the i128 Rust feature, since it
is stabilized. We leave byteorder's i128 feature in tact to
preserve compilation on Rust 1.12. | diff --git a/benches/bench.rs b/benches/bench.rs
index 845e489..8233a07 100644
--- a/benches/bench.rs
+++ b/benches/bench.rs
@@ -1,4 +1,3 @@
-#![cfg_attr(feature = "i128", feature(i128))]
#![feature(test)]
extern crate byteorder;
diff --git a/src/lib.rs b/src/lib.rs
index eb20a81..a4a7add 100644
--- a/src/lib.rs
++... | 2 | 0 | 7 |
f7cd70af3a3b3deaa4ff6baf89c0a0efef19df91 | Trevor Spiteri | 2018-04-04T13:04:07 | remove unnecessary cfg in examples | diff --git a/src/lib.rs b/src/lib.rs
index a1de738..eb20a81 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1442,11 +1442,7 @@ pub trait ByteOrder
///
/// let mut numbers = [5, 65000];
/// BigEndian::from_slice_u16(&mut numbers);
- /// if cfg!(target_endian = "little") {
- /// assert_eq!(numbers, ... | 1 | 8 | 40 |
f2f7b44a14ecef10478016dd57a281b337ca511c | Bruce Mitchener | 2018-04-01T15:02:09 | doc: miscellaneous improvements | diff --git a/src/io.rs b/src/io.rs
index e57510d..9a66e79 100644
--- a/src/io.rs
+++ b/src/io.rs
@@ -3,15 +3,15 @@ use std::slice;
use ByteOrder;
-/// Extends `Read` with methods for reading numbers. (For `std::io`.)
+/// Extends [`Read`] with methods for reading numbers. (For `std::io`.)
///
/// Most of the met... | 2 | 69 | 19 |
deb58862ddc0d02142abb4ffed6a966ada0fdec6 | Andrew Gallant | 2018-04-01T14:58:57 | style: remove all uses of transmute
We should have done this from the start. Everything can be accomplished
via pointer casts. Benchmarks show negligible differences. | diff --git a/src/lib.rs b/src/lib.rs
index 9f668c5..d49d344 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -47,8 +47,8 @@ extern crate core;
use core::fmt::Debug;
use core::hash::Hash;
-use core::mem::transmute;
use core::ptr::copy_nonoverlapping;
+use core::slice;
#[cfg(feature = "std")]
pub use io::{ReadBytesEx... | 1 | 96 | 38 |
e00c2331f66b7b0909d4484fba8c76054ab843a5 | Andrew Gallant | 2018-04-01T14:58:12 | style: remove unnecessary mut | diff --git a/src/io.rs b/src/io.rs
index 0e32bf0..e57510d 100644
--- a/src/io.rs
+++ b/src/io.rs
@@ -623,7 +623,7 @@ pub trait ReadBytesExt: io::Read {
dst: &mut [u128],
) -> Result<()> {
{
- let mut buf = unsafe { slice_to_u8_mut(dst) };
+ let buf = unsafe { slice_to_u8_mut... | 1 | 2 | 2 |
46f1664cac87125a4dfdea32886fd1127e8f1bc4 | Bruce Mitchener | 2018-03-22T15:48:12 | clippy: fix a couple of markdown warnings | diff --git a/src/lib.rs b/src/lib.rs
index 0654e88..9f668c5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -149,7 +149,7 @@ mod private {
impl Sealed for super::BigEndian {}
}
-/// ByteOrder describes types that can serialize integers as bytes.
+/// `ByteOrder` describes types that can serialize integers as bytes.... | 1 | 2 | 2 |
bad7aee9a2dfe3cd0505b128bec57cfdbed39162 | Igor Gnatenko | 2017-12-31T17:37:53 | deps: bump quickcheck to 0.6 and rand to 0.4 | diff --git a/Cargo.toml b/Cargo.toml
index 27fbe22..bdbaa10 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,8 +17,8 @@ name = "byteorder"
bench = false
[dev-dependencies]
-quickcheck = { version = "0.5", default-features = false }
-rand = "0.3"
+quickcheck = { version = "0.6", default-features = false }
+rand = "0.... | 1 | 2 | 2 |
e81c405c955e67433aaac82fdf7bea65f13715c0 | Marcel Hellwig | 2017-12-08T15:16:24 | Use depcrated tag instead of pure documentation
Since nearly 2 years, there is a depcrated attribute, which can be used
https://github.com/rust-lang/rfcs/blob/master/text/1270-deprecation.md | diff --git a/src/io.rs b/src/io.rs
index c5645fa..0e32bf0 100644
--- a/src/io.rs
+++ b/src/io.rs
@@ -860,6 +860,7 @@ pub trait ReadBytesExt: io::Read {
/// assert_eq!([f32::consts::PI, 1.0], dst);
/// ```
#[inline]
+ #[deprecated(since="1.2.0", note="please use `read_f32_into` instead")]
fn read_... | 1 | 2 | 0 |
7f84f871314b438e3cf4e3342b86f308ccb9110c | Igor Gnatenko | 2017-11-30T16:22:13 | bump quickcheck to 0.5 | diff --git a/Cargo.toml b/Cargo.toml
index 55ec05e..27fbe22 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,7 +17,7 @@ name = "byteorder"
bench = false
[dev-dependencies]
-quickcheck = { version = "0.4", default-features = false }
+quickcheck = { version = "0.5", default-features = false }
rand = "0.3"
[feature... | 1 | 1 | 1 |
27b9144a7ef334c940ba2d133e41df912a673977 | Andrew Gallant | 2017-11-29T21:41:53 | remove more unsafe
This removes the `unsafe` annotation from
`read_{f32,f64}_into_unchecked` and deprecates the methods because the
`unchecked` name is no longer appropriate. We in turn add
`read_{f32,f64}_into` methods. | diff --git a/src/io.rs b/src/io.rs
index a4c4fb4..c5645fa 100644
--- a/src/io.rs
+++ b/src/io.rs
@@ -1,6 +1,5 @@
use std::io::{self, Result};
use std::slice;
-// use std::mem::transmute;
use ByteOrder;
@@ -787,11 +786,53 @@ pub trait ReadBytesExt: io::Read {
/// The given buffer is either filled completely ... | 1 | 96 | 21 |
1163111367cef7a85d48cb5b84d7889458d23974 | Andrew Gallant | 2017-11-29T21:19:21 | remove unnecessary unsafe
See also #105
Fixes #103 | diff --git a/src/io.rs b/src/io.rs
index 208596a..a4c4fb4 100644
--- a/src/io.rs
+++ b/src/io.rs
@@ -509,7 +509,7 @@ pub trait ReadBytesExt: io::Read {
#[inline]
fn read_u16_into<T: ByteOrder>(&mut self, dst: &mut [u16]) -> Result<()> {
{
- let mut buf = unsafe { slice_to_u8_mut(dst) };
+ ... | 2 | 21 | 61 |
fde8463d25dce294cd0a8e6e167c9fe98438ecd4 | Alexis Beingessner | 2017-11-24T01:10:07 | remove now-irrelevant snan test | diff --git a/src/lib.rs b/src/lib.rs
index 6612a27..085e5d4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2768,35 +2768,6 @@ mod test {
let n = LittleEndian::read_uint(&[1, 2, 3, 4, 5, 6, 7, 8], 5);
assert_eq!(n, 0x0504030201);
}
-
- #[test]
- fn read_snan() {
- use core::f32;
- ... | 1 | 0 | 29 |
1b1f206f3fcd3026ae8d4e43c3e61b286520ef22 | Alexis Beingessner | 2017-11-15T20:31:22 | make int->float conversion a transmute
This is the mirror commit to https://github.com/rust-lang/rust/pull/46012 | diff --git a/src/lib.rs b/src/lib.rs
index 35c0069..6612a27 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2185,40 +2185,12 @@ impl ByteOrder for LittleEndian {
#[inline]
fn safe_u32_bits_to_f32(u: u32) -> f32 {
- use core::f32::NAN;
-
- const EXP_MASK: u32 = 0x7F800000;
- const FRACT_MASK: u32 = 0x007FFFFF;... | 1 | 2 | 30 |
098064b8c94c42e86deb7689cb4648ca39f54b2c | Josh Stone | 2017-11-13T19:26:47 | Fix prop_ext_[u]int_*::native_endian on BE targets
The similar `big_endian` tests were using an offset to read from the
end of the written `u64`, but the `native_endian` tests were reading
directly, just like the `little_endian` tests. That's of course only
correct when the target actually is little endian.
That `bi... | diff --git a/src/lib.rs b/src/lib.rs
index b60fe7c..35c0069 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2865,9 +2865,8 @@ mod stdtests {
fn prop(n: $ty_int) -> bool {
let mut wtr = vec![];
wtr.$write::<BigEndian>(n.clone()).unwrap();
- ... | 1 | 8 | 4 |
2dfff19478d2778d3dbaedcacb10f75c100f0882 | Martin Geisler | 2017-07-24T22:24:30 | Cleanup CI badge
The `repository` key only takes the username and repository name, not a full URL (the default `service` is GitHub).
The `branch` key defaults to `master` so I removed it for simplicity. | diff --git a/Cargo.toml b/Cargo.toml
index 3705bd2..681b70a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -29,4 +29,4 @@ i128 = []
opt-level = 3
[badges]
-travis-ci = { repository = "https://github.com/BurntSushi/byteorder", branch = "master" }
+travis-ci = { repository = "BurntSushi/byteorder" } | 1 | 1 | 1 |
ef7f25767cb199a5738b2bc530d9a2a9a49abd7f | Andrew Gallant | 2017-07-09T17:10:55 | slices: add slice methods for ReadBytesExt
As a consequence, this also introduces methods for doing endian
conversion on slices in-place. | diff --git a/src/io.rs b/src/io.rs
index 1650823..208596a 100644
--- a/src/io.rs
+++ b/src/io.rs
@@ -1,4 +1,6 @@
use std::io::{self, Result};
+use std::slice;
+// use std::mem::transmute;
use ByteOrder;
@@ -431,12 +433,16 @@ pub trait ReadBytesExt: io::Read {
/// Read a big-endian single-precision floating p... | 2 | 771 | 7 |
3477a8c7b7dc4c74fe3edbb53777966dfcf354a5 | Andrew Gallant | 2017-07-09T01:42:25 | rename new.rs to io.rs
In the long ago, "new" referred to the "new I/O module" after I/O reform
in the pre-1.0 days. | diff --git a/src/new.rs b/src/io.rs
similarity index 100%
rename from src/new.rs
rename to src/io.rs
diff --git a/src/lib.rs b/src/lib.rs
index 96f7116..3ad2cd4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -51,10 +51,10 @@ use core::mem::transmute;
use core::ptr::copy_nonoverlapping;
#[cfg(feature = "std")]
-pub use... | 2 | 2 | 2 |
2f0eb5f16630f5be441a36b63d3d6c5cd78bdb62 | Andrew Gallant | 2017-07-09T01:42:06 | add benchmarks for slice serialization | diff --git a/benches/bench.rs b/benches/bench.rs
index c03c5c2..845e489 100644
--- a/benches/bench.rs
+++ b/benches/bench.rs
@@ -2,6 +2,7 @@
#![feature(test)]
extern crate byteorder;
+extern crate rand;
extern crate test;
macro_rules! bench_num {
@@ -252,3 +253,68 @@ bench_num!(int128_15, read_int128,
#[cfg(fe... | 1 | 66 | 0 |
f3433f4d50a98509615e6044739dd16f5dec09e4 | Andrew Gallant | 2017-07-09T01:41:56 | add slice methods
This commit builds on PR #91 by @newpavlov to add methods to the ByteOrder
trait that permit serializing/deserializing contiguous sequences of
integers to/from byte buffers. | diff --git a/src/lib.rs b/src/lib.rs
index 876bd45..96f7116 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -312,258 +312,6 @@ pub trait ByteOrder
#[cfg(feature = "i128")]
fn read_uint128(buf: &[u8], nbytes: usize) -> u128;
- /// Reads unsigned 16 bit integers from `buf` to `dst`.
- ///
- /// # Panics
... | 1 | 680 | 405 |
f1df84cbf02a14233958e6a8aa3973d052322f04 | Andrew Gallant | 2017-07-09T01:40:45 | add BE and LE type aliases | diff --git a/src/lib.rs b/src/lib.rs
index 4142b1c..876bd45 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1388,6 +1388,9 @@ impl Default for BigEndian {
}
}
+/// A type alias for `BigEndian`.
+pub type BE = BigEndian;
+
/// Defines little-endian serialization.
///
/// Note that this type has no value construc... | 1 | 6 | 0 |
ef6d19e8369a4016fe797b15ad076274f9a24664 | Andrew Gallant | 2017-07-09T01:40:22 | fix formatting | diff --git a/src/lib.rs b/src/lib.rs
index 7bfa45b..4142b1c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -142,7 +142,8 @@ fn pack_size128(n: u128) -> usize {
}
mod private {
- /// Sealed stops crates other than byteorder from implementing any traits that use it.
+ /// Sealed stops crates other than byteorder f... | 1 | 5 | 4 |
39aee20b144a69c196bde258f70bf7c4e9b9c4c7 | Artyom Pavlov | 2017-06-05T15:50:02 | Slice methods addition
Closes #63 | diff --git a/src/lib.rs b/src/lib.rs
index 7b86779..7bfa45b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -309,6 +309,260 @@ pub trait ByteOrder
#[cfg(feature = "i128")]
fn read_uint128(buf: &[u8], nbytes: usize) -> u128;
+ /// Reads unsigned 16 bit integers from `buf` to `dst`.
+ ///
+ /// # Panics
... | 1 | 611 | 0 |
ee399d53e88950c025b1cd1b3bdbe0571df95efc | Andrew Gallant | 2017-07-08T14:03:15 | floats: remove unnecessary transmute
Thanks @le-jzr! | diff --git a/src/lib.rs b/src/lib.rs
index 3740f64..7b86779 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1172,7 +1172,7 @@ fn safe_u32_bits_to_f32(u: u32) -> f32 {
// NaNs differently. Therefore, to be safe, we pass a known quiet
// NaN if u is any kind of NaN. The check above only assumes
//... | 1 | 2 | 2 |
6136293b6cc3226a477d7c1597d39163242c128d | Sam Whited | 2017-03-01T05:14:28 | floats: make reading floats safe
This commit modifies the existing read_f32/read_f64 methods to
guarantee their safety by returning NaNs when signaling NaNs are
detected.
Fixes #71 | diff --git a/src/lib.rs b/src/lib.rs
index f4a9c7f..3740f64 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -608,6 +608,8 @@ pub trait ByteOrder
/// Reads a IEEE754 single-precision (4 bytes) floating point number.
///
+ /// The return value is always defined; signaling NaN's may be turned into quiet NaN's.
... | 1 | 73 | 2 |
4a4f640cb0fe6f06116fb8c9ccb7aaadc65c881a | Andrew Gallant | 2017-07-08T12:50:29 | Cargo.toml: disable quickcheck's default features
This prevents the env_logger/regex dep from being roped in during tests. | diff --git a/Cargo.toml b/Cargo.toml
index fd0270e..5cd0d5e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,7 +17,7 @@ name = "byteorder"
bench = false
[dev-dependencies]
-quickcheck = "0.4"
+quickcheck = { version = "0.4", default-features = false }
rand = "0.3"
[features]
@@ -29,5 +29,4 @@ i128 = []
opt-leve... | 1 | 1 | 2 |
9a09b5efb7103472520bf3a6337beb0b2b147866 | Sam Whited | 2017-03-29T15:02:13 | Add more examples for {u,i}128 methods | diff --git a/src/lib.rs b/src/lib.rs
index 0efac0a..f4a9c7f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -392,6 +392,18 @@ pub trait ByteOrder
/// # Panics
///
/// Panics when `buf.len() < 16`.
+ ///
+ /// # Examples
+ ///
+ /// Write and read `u128` numbers in little endian order:
+ ///
+ ... | 1 | 72 | 0 |
d36d4ce33994277e16b1525b36a2e7063a8fd7ab | Sebastian Dröge | 2017-04-23T12:34:57 | Fix some typos in the docs
Unsigned integer types were given for the signed functions of the
ByteOrder trait | diff --git a/src/lib.rs b/src/lib.rs
index 0b6d081..0efac0a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -432,7 +432,7 @@ pub trait ByteOrder
///
/// # Examples
///
- /// Write and read `u16` numbers in little endian order:
+ /// Write and read `i16` numbers in little endian order:
///
///... | 1 | 6 | 6 |
30b20c024a7c7d15fb35f4028870f522d1dda28d | Sebastian Dröge | 2017-04-23T12:35:25 | Add 24 bit integer read/write functions
The trait has default implementations around read_int/read_uint to keep
all existing instances working without changes, but implementations can
implement something more optimal if needed. | diff --git a/src/lib.rs b/src/lib.rs
index 4ab6bbb..0b6d081 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -189,6 +189,27 @@ pub trait ByteOrder
/// Panics when `buf.len() < 2`.
fn read_u16(buf: &[u8]) -> u16;
+ /// Reads an unsigned 24 bit integer from `buf`, stored in u32.
+ ///
+ /// # Panics
+ ... | 2 | 171 | 0 |
f8e7685b3a81c52f5448fd77fb4e0535bc92f880 | Sam Whited | 2017-03-29T14:41:07 | Add examples for {u,i}128 methods | diff --git a/src/lib.rs b/src/lib.rs
index eaac4f9..4ab6bbb 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -232,6 +232,18 @@ pub trait ByteOrder
/// # Panics
///
/// Panics when `buf.len() < 16`.
+ ///
+ /// # Examples
+ ///
+ /// Write and read `u128` numbers in little endian order:
+ ///
+ ... | 1 | 24 | 0 |
6dd2f2dee72c3c26ecf8edecd7971a1c38ad0039 | Sam Whited | 2017-03-28T21:15:55 | Add example to Read methods | diff --git a/src/new.rs b/src/new.rs
index 79ef5fd..b3b0ce8 100644
--- a/src/new.rs
+++ b/src/new.rs
@@ -31,6 +31,19 @@ pub trait ReadBytesExt: io::Read {
/// This method returns the same errors as [`Read::read_exact`].
///
/// [`Read::read_exact`]: https://doc.rust-lang.org/std/io/trait.Read.html#method... | 1 | 146 | 0 |
aab9955a3d5efc8fb3d14ccbacae4b26dd14b283 | Sam Whited | 2017-03-28T18:20:28 | Add examples to most methods
Updates #75
Updates #76 | diff --git a/src/lib.rs b/src/lib.rs
index 3616e01..713b72a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -140,6 +140,18 @@ pub trait ByteOrder
/// # Panics
///
/// Panics when `buf.len() < 4`.
+ ///
+ /// # Examples
+ ///
+ /// Write and read `u32` numbers in little endian order:
+ ///
+ ... | 1 | 268 | 0 |
3ec105c08d1ba443f802b251f239161e771de94a | Sam Whited | 2017-03-28T16:57:12 | Seal ByteOrder trait against external implementations
Fixes #69
Updates #76 | diff --git a/src/lib.rs b/src/lib.rs
index 035aca6..3616e01 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -87,6 +87,13 @@ fn pack_size(n: u64) -> usize {
}
}
+mod private {
+ /// Sealed stops crates other than byteorder from implementing any traits that use it.
+ pub trait Sealed{}
+ impl Sealed for supe... | 1 | 10 | 1 |
e7cb5abf22b7acc99bc7becc1572615f6cb6662f | Sam Whited | 2017-03-28T16:40:27 | Add travis-ci shield to manifest
Fixes #74
See #76 | diff --git a/Cargo.toml b/Cargo.toml
index f8139ba..92a9f70 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -26,3 +26,7 @@ std = []
[profile.bench]
opt-level = 3
+
+[badges]
+
+travis-ci = { repository = "https://github.com/BurntSushi/byteorder", branch = "master" } | 1 | 4 | 0 |
ea9fbbc614586a4815a798009452f80da1f130a6 | Brian Anderson | 2017-03-04T21:19:17 | Add 'Errors' headers. Fixes #72 | diff --git a/src/new.rs b/src/new.rs
index c1df717..79ef5fd 100644
--- a/src/new.rs
+++ b/src/new.rs
@@ -25,6 +25,12 @@ pub trait ReadBytesExt: io::Read {
///
/// Note that since this reads a single byte, no byte order conversions
/// are used. It is included for completeness.
+ ///
+ /// # Errors
... | 1 | 138 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.