mirror of https://git.sr.ht/~stygianentity/bincode
Modernize CI (#311)
Switches our CI from Travis-CI to Github Actions. At the same time this also turns on clippy and rustfmt linting.
This commit is contained in:
parent
ae8c162d49
commit
8839b0600d
|
|
@ -0,0 +1,95 @@
|
||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
name: Check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
rust:
|
||||||
|
- stable
|
||||||
|
- beta
|
||||||
|
- nightly
|
||||||
|
- 1.18.0 # MSRV
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
name: Checkout
|
||||||
|
|
||||||
|
- uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: ${{ matrix.rust }}
|
||||||
|
override: true
|
||||||
|
name: Install Rust ${{ matrix.rust }}
|
||||||
|
|
||||||
|
- uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: check
|
||||||
|
name: Run `cargo check`
|
||||||
|
|
||||||
|
- uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: check
|
||||||
|
args: --examples
|
||||||
|
name: Check examples
|
||||||
|
if: matrix.rust != '1.18.0'
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
rust:
|
||||||
|
- stable
|
||||||
|
- beta
|
||||||
|
- nightly
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
name: Checkout
|
||||||
|
|
||||||
|
- uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: ${{ matrix.rust }}
|
||||||
|
override: true
|
||||||
|
name: Install Rust ${{ matrix.rust }}
|
||||||
|
|
||||||
|
- uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
|
name: Run `cargo test`
|
||||||
|
|
||||||
|
lints:
|
||||||
|
name: Lints
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
name: Checkout
|
||||||
|
|
||||||
|
- uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: stable
|
||||||
|
override: true
|
||||||
|
components: rustfmt, clippy
|
||||||
|
name: Install Rust stable
|
||||||
|
|
||||||
|
- uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: fmt
|
||||||
|
args: --all -- --check
|
||||||
|
name: Run `cargo fmt`
|
||||||
|
|
||||||
|
- uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: clippy
|
||||||
|
args: -- -D warnings
|
||||||
|
name: Run `cargo clippy`
|
||||||
16
.travis.yml
16
.travis.yml
|
|
@ -1,16 +0,0 @@
|
||||||
language: rust
|
|
||||||
|
|
||||||
rust:
|
|
||||||
- stable
|
|
||||||
- beta
|
|
||||||
- nightly
|
|
||||||
|
|
||||||
script:
|
|
||||||
- cargo test
|
|
||||||
- cargo package
|
|
||||||
- cd target/package/bincode-* && cargo test
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- rust: 1.18.0
|
|
||||||
script: cargo build
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<img align="right" src="./logo.png" />
|
<img align="right" src="./logo.png" />
|
||||||
|
|
||||||
[](https://travis-ci.com/servo/bincode)
|

|
||||||
[](https://crates.io/crates/bincode)
|
[](https://crates.io/crates/bincode)
|
||||||
[](https://opensource.org/licenses/MIT)
|
[](https://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ impl<O: Options, E: ByteOrder> WithOtherEndian<O, E> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn new(options: O) -> WithOtherEndian<O, E> {
|
pub(crate) fn new(options: O) -> WithOtherEndian<O, E> {
|
||||||
WithOtherEndian {
|
WithOtherEndian {
|
||||||
options: options,
|
options,
|
||||||
_endian: PhantomData,
|
_endian: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,7 @@ pub(crate) struct Deserializer<R, O: Options> {
|
||||||
impl<'de, R: BincodeRead<'de>, O: Options> Deserializer<R, O> {
|
impl<'de, R: BincodeRead<'de>, O: Options> Deserializer<R, O> {
|
||||||
/// Creates a new Deserializer with a given `Read`er and a size_limit.
|
/// Creates a new Deserializer with a given `Read`er and a size_limit.
|
||||||
pub(crate) fn new(r: R, options: O) -> Deserializer<R, O> {
|
pub(crate) fn new(r: R, options: O) -> Deserializer<R, O> {
|
||||||
Deserializer {
|
Deserializer { reader: r, options }
|
||||||
reader: r,
|
|
||||||
options: options,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_bytes(&mut self, count: u64) -> Result<()> {
|
fn read_bytes(&mut self, count: u64) -> Result<()> {
|
||||||
|
|
@ -149,7 +146,7 @@ where
|
||||||
let mut buf = [0u8; 4];
|
let mut buf = [0u8; 4];
|
||||||
|
|
||||||
// Look at the first byte to see how many bytes must be read
|
// Look at the first byte to see how many bytes must be read
|
||||||
let _ = self.reader.read_exact(&mut buf[..1])?;
|
self.reader.read_exact(&mut buf[..1])?;
|
||||||
let width = utf8_char_width(buf[0]);
|
let width = utf8_char_width(buf[0]);
|
||||||
if width == 1 {
|
if width == 1 {
|
||||||
return visitor.visit_char(buf[0] as char);
|
return visitor.visit_char(buf[0] as char);
|
||||||
|
|
@ -165,7 +162,7 @@ where
|
||||||
let res = str::from_utf8(&buf[..width])
|
let res = str::from_utf8(&buf[..width])
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|s| s.chars().next())
|
.and_then(|s| s.chars().next())
|
||||||
.ok_or(error())?;
|
.ok_or_else(error)?;
|
||||||
visitor.visit_char(res)
|
visitor.visit_char(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -251,10 +248,8 @@ where
|
||||||
{
|
{
|
||||||
if self.len > 0 {
|
if self.len > 0 {
|
||||||
self.len -= 1;
|
self.len -= 1;
|
||||||
let value = serde::de::DeserializeSeed::deserialize(
|
let value =
|
||||||
seed,
|
serde::de::DeserializeSeed::deserialize(seed, &mut *self.deserializer)?;
|
||||||
&mut *self.deserializer,
|
|
||||||
)?;
|
|
||||||
Ok(Some(value))
|
Ok(Some(value))
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
|
|
@ -268,7 +263,7 @@ where
|
||||||
|
|
||||||
visitor.visit_seq(Access {
|
visitor.visit_seq(Access {
|
||||||
deserializer: self,
|
deserializer: self,
|
||||||
len: len,
|
len,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -313,10 +308,8 @@ where
|
||||||
{
|
{
|
||||||
if self.len > 0 {
|
if self.len > 0 {
|
||||||
self.len -= 1;
|
self.len -= 1;
|
||||||
let key = serde::de::DeserializeSeed::deserialize(
|
let key =
|
||||||
seed,
|
serde::de::DeserializeSeed::deserialize(seed, &mut *self.deserializer)?;
|
||||||
&mut *self.deserializer,
|
|
||||||
)?;
|
|
||||||
Ok(Some(key))
|
Ok(Some(key))
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
|
|
@ -327,10 +320,7 @@ where
|
||||||
where
|
where
|
||||||
V: serde::de::DeserializeSeed<'de>,
|
V: serde::de::DeserializeSeed<'de>,
|
||||||
{
|
{
|
||||||
let value = serde::de::DeserializeSeed::deserialize(
|
let value = serde::de::DeserializeSeed::deserialize(seed, &mut *self.deserializer)?;
|
||||||
seed,
|
|
||||||
&mut *self.deserializer,
|
|
||||||
)?;
|
|
||||||
Ok(value)
|
Ok(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -343,7 +333,7 @@ where
|
||||||
|
|
||||||
visitor.visit_map(Access {
|
visitor.visit_map(Access {
|
||||||
deserializer: self,
|
deserializer: self,
|
||||||
len: len,
|
len,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use error::Result;
|
use error::Result;
|
||||||
use serde;
|
use serde;
|
||||||
use std::{io, slice};
|
use std::io;
|
||||||
|
|
||||||
/// An optional Read trait for advanced Bincode usage.
|
/// An optional Read trait for advanced Bincode usage.
|
||||||
///
|
///
|
||||||
|
|
@ -83,7 +83,7 @@ impl<'storage> io::Read for SliceReader<'storage> {
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn read_exact(&mut self, out: &mut [u8]) -> io::Result<()> {
|
fn read_exact(&mut self, out: &mut [u8]) -> io::Result<()> {
|
||||||
self.read(out).map(|_|())
|
self.read(out).map(|_| ())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,10 +101,10 @@ impl<R: io::Read> io::Read for IoReader<R> {
|
||||||
impl<'storage> SliceReader<'storage> {
|
impl<'storage> SliceReader<'storage> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn unexpected_eof() -> Box<::ErrorKind> {
|
fn unexpected_eof() -> Box<::ErrorKind> {
|
||||||
return Box::new(::ErrorKind::Io(io::Error::new(
|
Box::new(::ErrorKind::Io(io::Error::new(
|
||||||
io::ErrorKind::UnexpectedEof,
|
io::ErrorKind::UnexpectedEof,
|
||||||
"",
|
"",
|
||||||
)));
|
)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
#![allow(unknown_lints, bare_trait_objects, deprecated)]
|
||||||
|
|
||||||
//! Bincode is a crate for encoding and decoding using a tiny binary
|
//! Bincode is a crate for encoding and decoding using a tiny binary
|
||||||
//! serialization strategy. Using it, you can easily go from having
|
//! serialization strategy. Using it, you can easily go from having
|
||||||
|
|
|
||||||
|
|
@ -224,10 +224,6 @@ pub(crate) struct SizeChecker<O: Options> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<O: Options> SizeChecker<O> {
|
impl<O: Options> SizeChecker<O> {
|
||||||
pub fn new(options: O) -> SizeChecker<O> {
|
|
||||||
SizeChecker { options: options }
|
|
||||||
}
|
|
||||||
|
|
||||||
fn add_raw(&mut self, size: u64) -> Result<()> {
|
fn add_raw(&mut self, size: u64) -> Result<()> {
|
||||||
self.options.limit().add(size)
|
self.options.limit().add(size)
|
||||||
}
|
}
|
||||||
|
|
@ -755,7 +751,7 @@ fn encode_utf8(c: char) -> EncodeUtf8 {
|
||||||
buf[3] = (code & 0x3F) as u8 | TAG_CONT;
|
buf[3] = (code & 0x3F) as u8 | TAG_CONT;
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
EncodeUtf8 { buf: buf, pos: pos }
|
EncodeUtf8 { buf, pos }
|
||||||
}
|
}
|
||||||
|
|
||||||
struct EncodeUtf8 {
|
struct EncodeUtf8 {
|
||||||
|
|
|
||||||
|
|
@ -334,12 +334,10 @@ fn test_serialized_size_bounded() {
|
||||||
assert!(config().limit(7).serialized_size(&0u64).is_err());
|
assert!(config().limit(7).serialized_size(&0u64).is_err());
|
||||||
assert!(config().limit(7).serialized_size(&"").is_err());
|
assert!(config().limit(7).serialized_size(&"").is_err());
|
||||||
assert!(config().limit(8 + 0).serialized_size(&"a").is_err());
|
assert!(config().limit(8 + 0).serialized_size(&"a").is_err());
|
||||||
assert!(
|
assert!(config()
|
||||||
config()
|
|
||||||
.limit(8 + 3 * 4 - 1)
|
.limit(8 + 3 * 4 - 1)
|
||||||
.serialized_size(&vec![0u32, 1u32, 2u32])
|
.serialized_size(&vec![0u32, 1u32, 2u32])
|
||||||
.is_err()
|
.is_err());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -423,7 +421,8 @@ fn test_oom_protection() {
|
||||||
.serialize(&FakeVec {
|
.serialize(&FakeVec {
|
||||||
len: 0xffffffffffffffffu64,
|
len: 0xffffffffffffffffu64,
|
||||||
byte: 1,
|
byte: 1,
|
||||||
}).unwrap();
|
})
|
||||||
|
.unwrap();
|
||||||
let y: Result<Vec<u8>> = config()
|
let y: Result<Vec<u8>> = config()
|
||||||
.limit(10)
|
.limit(10)
|
||||||
.deserialize_from(&mut Cursor::new(&x[..]));
|
.deserialize_from(&mut Cursor::new(&x[..]));
|
||||||
|
|
@ -581,7 +580,8 @@ fn test_zero_copy_parse_deserialize_into() {
|
||||||
slice: &encoded[..],
|
slice: &encoded[..],
|
||||||
},
|
},
|
||||||
&mut target,
|
&mut target,
|
||||||
).unwrap();
|
)
|
||||||
|
.unwrap();
|
||||||
assert_eq!(target, f);
|
assert_eq!(target, f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue