Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare v0.1.3 semver-trick release for nb 1.0 #34

Merged
merged 5 commits into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @rust-embedded/hal
7 changes: 7 additions & 0 deletions .github/bors.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
block_labels = ["needs-decision"]
delete_merged_branches = true
required_approvals = 1
status = [
"ci-linux (stable, x86_64-unknown-linux-gnu)",
"ci-linux (1.35.0, x86_64-unknown-linux-gnu)",
]
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
on:
push:
branches: [ staging, trying, master ]
pull_request:

name: Continuous integration

env:
RUSTFLAGS: '-D warnings'

jobs:
ci-linux:
runs-on: ubuntu-latest
strategy:
matrix:
# All generated code should be running on stable now
rust: [stable]

# The default target we're compiling on and for
TARGET: [x86_64-unknown-linux-gnu]

include:
# Test MSRV
- rust: 1.35.0
TARGET: x86_64-unknown-linux-gnu

# Test nightly but don't fail
- rust: nightly
experimental: true
TARGET: x86_64-unknown-linux-gnu

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.TARGET }}
override: true
- uses: actions-rs/cargo@v1
with:
command: check
args: --target=${{ matrix.TARGET }}
- uses: actions-rs/cargo@v1
with:
command: test
args: --target=${{ matrix.TARGET }}
24 changes: 24 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
on:
push:
branches: [ staging, trying, master ]
pull_request:

name: Clippy check

env:
RUSTFLAGS: '-D warnings'

jobs:
clippy_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: clippy
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
23 changes: 23 additions & 0 deletions .github/workflows/rustfmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
on:
push:
branches: [ staging, trying, master ]
pull_request:

name: Code formatting check

jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
33 changes: 0 additions & 33 deletions .travis.yml

This file was deleted.

12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [v0.1.3] - 2020-07-07

This release of the 0.1 version exists for compatibility with 1.0.0.
There are no functional changes compared to 0.1.2.

## [v0.1.2] - 2019-04-21

### Added
Expand All @@ -26,6 +31,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

Initial release

[Unreleased]: https://github.com/japaric/nb/compare/v0.1.2...HEAD
[v0.1.2]: https://github.com/japaric/nb/compare/v0.1.1...v0.1.2
[v0.1.1]: https://github.com/japaric/nb/compare/v0.1.0...v0.1.1
[Unreleased]: https://github.com/rust-embedded/nb/compare/v0.1.3...HEAD
[v0.1.3]: https://github.com/rust-embedded/nb/compare/v0.1.2...v0.1.3
[v0.1.2]: https://github.com/rust-embedded/nb/compare/v0.1.1...v0.1.2
[v0.1.1]: https://github.com/rust-embedded/nb/compare/v0.1.0...v0.1.1
15 changes: 13 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,22 @@ description = "Minimal non-blocking I/O layer"
keywords = ["await", "futures", "IO"]
license = "MIT OR Apache-2.0"
name = "nb"
repository = "https://github.com/japaric/nb"
version = "0.1.2"
repository = "https://github.com/rust-embedded/nb"
homepage = "https://github.com/rust-embedded/nb"
documentation = "https://docs.rs/nb"
readme = "README.md"
version = "0.1.3" # remember to update html_root_url

[features]
unstable = []

[dependencies]
nb = "1"

[dev-dependencies]
futures = "0.1.17"

[lib]
# Due to the semver-trick, doctests do not compile:
# error[E0465]: multiple rlib candidates for `nb` found
doctest = false
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

> Minimal and reusable non-blocking I/O layer

This project is developed and maintained by the [HAL team][team].

## [Documentation](https://docs.rs/nb)

## License
Expand All @@ -19,3 +21,5 @@ at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.

[team]: https://github.com/rust-embedded/wg#the-hal-team
20 changes: 0 additions & 20 deletions ci/after_success.sh

This file was deleted.

7 changes: 0 additions & 7 deletions ci/install.sh

This file was deleted.

10 changes: 0 additions & 10 deletions ci/script.sh

This file was deleted.

94 changes: 10 additions & 84 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,53 +355,10 @@
//! ```

#![no_std]
#![deny(warnings)]
#![doc(html_root_url = "https://docs.rs/nb/0.1.3")]

use core::fmt;

/// A non-blocking result
pub type Result<T, E> = ::core::result::Result<T, Error<E>>;

/// A non-blocking error
///
/// The main use of this enum is to add a `WouldBlock` variant to an existing
/// error enum.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum Error<E> {
/// A different kind of error
Other(E),
/// This operation requires blocking behavior to complete
WouldBlock,
}

impl<E> fmt::Debug for Error<E>
where
E: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Error::Other(ref e) => fmt::Debug::fmt(e, f),
Error::WouldBlock => f.write_str("WouldBlock"),
}
}
}

impl<E> Error<E> {
/// Maps an `Error<E>` to `Error<T>` by applying a function to a contained
/// `Error::Other` value, leaving an `Error::WouldBlock` value untouched.
pub fn map<T, F>(self, op: F) -> Error<T> where F: FnOnce(E) -> T {
match self {
Error::Other(e) => Error::Other(op(e)),
Error::WouldBlock => Error::WouldBlock,
}
}
}

impl<E> From<E> for Error<E> {
fn from(error: E) -> Error<E> {
Error::Other(error)
}
}
extern crate nb;
pub use nb::{block, Error, Result};

/// Await operation (*won't work until the language gains support for
/// generators*)
Expand Down Expand Up @@ -429,47 +386,18 @@ macro_rules! await {
loop {
#[allow(unreachable_patterns)]
match $e {
Err($crate::Error::Other(e)) => {
Err($crate::Error::Other(e)) =>
{
#[allow(unreachable_code)]
break Err(e)
},
Err($crate::Error::WouldBlock) => {}, // yield (see below)
}
Err($crate::Error::WouldBlock) => {} // yield (see below)
Ok(x) => break Ok(x),
}

yield
}
}
}

/// Turns the non-blocking expression `$e` into a blocking operation.
///
/// This is accomplished by continuously calling the expression `$e` until it no
/// longer returns `Error::WouldBlock`
///
/// # Input
///
/// An expression `$e` that evaluates to `nb::Result<T, E>`
///
/// # Output
///
/// - `Ok(t)` if `$e` evaluates to `Ok(t)`
/// - `Err(e)` if `$e` evaluates to `Err(nb::Error::Other(e))`
#[macro_export]
macro_rules! block {
($e:expr) => {
loop {
#[allow(unreachable_patterns)]
match $e {
Err($crate::Error::Other(e)) => {
#[allow(unreachable_code)]
break Err(e)
},
Err($crate::Error::WouldBlock) => {},
Ok(x) => break Ok(x),
}
}
}
};
}

/// Future adapter
Expand Down Expand Up @@ -503,10 +431,8 @@ macro_rules! try_nb {
($e:expr) => {
match $e {
Err($crate::Error::Other(e)) => return Err(e),
Err($crate::Error::WouldBlock) => {
return Ok(::futures::Async::NotReady)
},
Err($crate::Error::WouldBlock) => return Ok(::futures::Async::NotReady),
Ok(x) => x,
}
}
};
}