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

feat: Mio 1.x.x [fail due to CI rate limiting] #22

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ task:
fingerprint_script: cat Cargo.lock 2> /dev/null || true
check_script:
- cargo check
- cargo check --features mio_08
- cargo check --features mio_1xx
- cargo check --features tokio
test_script:
- cargo test --all-features --no-fail-fast -- --test-threads=1 --nocapture
Expand All @@ -70,7 +70,7 @@ task:
- rustc --version
check_script:
- cargo check -Z minimal-versions -Z avoid-dev-deps
- cargo check -Z minimal-versions -Z avoid-dev-deps --features mio_08
- cargo check -Z minimal-versions -Z avoid-dev-deps --features mio_1xx
- cargo check -Z minimal-versions -Z avoid-dev-deps --features tokio
# neither -Z minimal-versions nor -Z direct-minimal-versions work with tokio 1
# and it's a dev-dependency so can't test anything else either
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exclude = ["tests", "src/bin", ".vscode"]
libc = "0.2.90" # peer credentials for DragonFly BSD and NetBSD, SO_PEERSEC on all Linux architectures
# enabling this feature implements the extension traits for mio 0.8's unix socket types
# and Source for this crate's non-blocking seqpacket types.
mio_08 = { package = "mio", version = "0.8", features = ["os-ext", "net"], optional = true }
mio_1xx = { package = "mio", version = "1", features = ["os-ext", "net"], optional = true }
# .28 for AsyncFd.async_io() helper
tokio = { version = "1.28", features = ["net"], optional=true }

Expand All @@ -26,4 +26,4 @@ tokio = { version = "1.28", features = ["net"], optional=true }
tokio = { version = "1.28", features = ["io-util", "macros", "rt", 'rt-multi-thread'] }

[package.metadata.docs.rs]
features = ["mio_08", "tokio"]
features = ["mio_1xx", "tokio"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ Also, some OSes might return the original file descriptor without cloning it if

## mio integration

The `mio_08` feature makes the seqpacket types usable with [mio](https://github.com/tokio-rs/mio) version 0.8 (by implementing its `Source` trait for them),
The `mio_1xx` feature makes the seqpacket types usable with [mio](https://github.com/tokio-rs/mio) version 0.8 (by implementing its `Source` trait for them),
and implements this crates extension traits for the unix socket types in [`mio::net`](https://docs.rs/mio/latest/mio/net/index.html).

To enable it, add this to Cargo.toml:

```toml
[dependencies]
uds = {version="0.4.0", features=["mio_08"]}
uds = {version="0.4.0", features=["mio_1xx"]}
```

## tokio integration
Expand Down
4 changes: 2 additions & 2 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Version 0.4.0 (2023-08-14)
1.\* support might be implemented later.
* Remove mio 0.6, mio-uds & mio 0.7 support.
To simplify code and reduce combinations of features to test.
The feature for mio 0.8 support remains `"mio_08"`: `"mio"` is reserved for mio 1.0.
The feature for mio 0.8 support remains `"mio_1xx"`: `"mio"` is reserved for mio 1.0.

Version 0.3.0 (2023-08-14)
==========================
Expand All @@ -30,7 +30,7 @@ Version 0.3.0 (2023-08-14)
Use `recv_vectored()` with empty fd buffer if you want to know whether the packet was truncated.
* Remove default impl of `UnixDatagramExt::bind_unix_addr()`, and remove `Sized` bound on the trait.
* Stop quoting Unnamed in `UnixSocketaddr`'s `Debug` impl.
* Add mio_08 feature, for using this library with mio 0.8.
* Add mio_1xx feature, for using this library with mio 0.8.
* Require Rust 1.63.
(Mainly to make CI pass, so older versions will likely work.)

Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//! File-descriptor passing and abstract socket support
//! for stream and datagram sockets is provided via extension traits for
//! existing types in `std::os::unix::net` and from [mio](https://github.com/tokio-rs/mio)
//! (the latter is opt-in and must be enabled with `features=["mio_08"]` in Cargo.toml).
//! (the latter is opt-in and must be enabled with `features=["mio_1xx"]` in Cargo.toml).
//!
//! See README for status of operating system support and other general info.

Expand All @@ -34,8 +34,8 @@
)]

extern crate libc;
#[cfg(feature="mio_08")]
extern crate mio_08;
#[cfg(feature="mio_1xx")]
extern crate mio_1xx;
#[cfg(feature="tokio")]
extern crate tokio as tokio_crate;

Expand Down
30 changes: 15 additions & 15 deletions src/seqpacket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use std::time::Duration;

use libc::{SOCK_SEQPACKET, MSG_EOR, MSG_PEEK, c_void, close, send, recv};

#[cfg(feature = "mio_08")]
use mio_08::{event::Source as Source_08, unix::SourceFd as SourceFd_08, Interest as Interest_08, Registry as Registry_08, Token as Token_08};
#[cfg(feature = "mio_1xx")]
use mio_1xx::{event::Source as Source_08, unix::SourceFd as SourceFd_08, Interest as Interest_08, Registry as Registry_08, Token as Token_08};

use crate::addr::*;
use crate::helpers::*;
Expand Down Expand Up @@ -43,7 +43,7 @@ macro_rules! impl_rawfd_traits {($type:tt) => {

/// Implements `mio::Evented` and `mio::Source` for a fd-wrapping type.
macro_rules! impl_mio_if_enabled {($type:tt) => {
#[cfg(feature = "mio_08")]
#[cfg(feature = "mio_1xx")]
impl Source_08 for $type {
fn register(&mut self, registry: &Registry_08, token: Token_08, interest: Interest_08)
-> Result<(), io::Error> {
Expand All @@ -58,7 +58,7 @@ macro_rules! impl_mio_if_enabled {($type:tt) => {
}
}

#[cfg(feature = "mio_08")]
#[cfg(feature = "mio_1xx")]
impl<'a> Source_08 for &'a $type {
fn register(&mut self, registry: &Registry_08, token: Token_08, interest: Interest_08)
-> Result<(), io::Error> {
Expand Down Expand Up @@ -691,7 +691,7 @@ impl UnixSeqpacketListener {
/// This type can be used with mio if one of the mio features are enabled:
///
/// ```toml
/// uds = { version = "x.y", features=["mio_08"] }
/// uds = { version = "x.y", features=["mio_1xx"] }
/// ```
///
/// # Examples
Expand Down Expand Up @@ -719,11 +719,11 @@ impl UnixSeqpacketListener {
///
/// Registering with mio (v0.8):
///
#[cfg_attr(all(feature="mio_08", not(target_vendor="apple")), doc="```")]
#[cfg_attr(all(feature="mio_08", target_vendor="apple"), doc="```no_run")]
#[cfg_attr(not(feature="mio_08"), doc="```no_compile")]
#[cfg_attr(all(feature="mio_1xx", not(target_vendor="apple")), doc="```")]
#[cfg_attr(all(feature="mio_1xx", target_vendor="apple"), doc="```no_run")]
#[cfg_attr(not(feature="mio_1xx"), doc="```no_compile")]
/// use uds::nonblocking::UnixSeqpacketConn;
/// use mio_08::{Poll, Events, Token, Interest};
/// use mio_1xx::{Poll, Events, Token, Interest};
/// use std::io::ErrorKind;
///
/// let (mut a, b) = UnixSeqpacketConn::pair()
Expand Down Expand Up @@ -963,10 +963,10 @@ impl NonblockingUnixSeqpacketConn {
/// returns non-blocking [connection sockets](struct.NonblockingUnixSeqpacketConn.html)
/// and doesn't block if no client `connect()`ions are pending.
///
/// This type can be used with mio if the `mio_08` feature is enabled:
/// This type can be used with mio if the `mio_1xx` feature is enabled:
///
/// ```toml
/// uds = { version = "x.y", features=["mio_08"] }
/// uds = { version = "x.y", features=["mio_1xx"] }
/// ```
///
/// # Examples
Expand All @@ -993,11 +993,11 @@ impl NonblockingUnixSeqpacketConn {
///
/// Registering with mio v0.8:
///
#[cfg_attr(all(feature="mio_08", not(target_vendor="apple")), doc="```")]
#[cfg_attr(all(feature="mio_08", target_vendor="apple"), doc="```no_run")]
#[cfg_attr(not(feature="mio_08"), doc="```no_compile")]
#[cfg_attr(all(feature="mio_1xx", not(target_vendor="apple")), doc="```")]
#[cfg_attr(all(feature="mio_1xx", target_vendor="apple"), doc="```no_run")]
#[cfg_attr(not(feature="mio_1xx"), doc="```no_compile")]
/// use uds::nonblocking::{UnixSeqpacketListener, UnixSeqpacketConn};
/// use mio_08::{Poll, Events, Token, Interest};
/// use mio_1xx::{Poll, Events, Token, Interest};
/// use std::io::ErrorKind;
///
/// # let _ = std::fs::remove_file("seqpacket.sock");
Expand Down
22 changes: 11 additions & 11 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ impl UnixStreamExt for UnixStream {
}
}

#[cfg(feature = "mio_08")]
impl UnixStreamExt for mio_08::net::UnixStream {
#[cfg(feature = "mio_1xx")]
impl UnixStreamExt for mio_1xx::net::UnixStream {
fn connect_to_unix_addr(addr: &UnixSocketAddr) -> Result<Self, io::Error> {
let socket = Socket::new(SOCK_STREAM, true)?;
set_unix_addr(socket.as_raw_fd(), SetAddr::PEER, addr)?;
Expand Down Expand Up @@ -121,9 +121,9 @@ impl UnixListenerExt for UnixListener {
}
}

#[cfg(feature = "mio_08")]
impl UnixListenerExt for mio_08::net::UnixListener {
type Conn = mio_08::net::UnixStream;
#[cfg(feature = "mio_1xx")]
impl UnixListenerExt for mio_1xx::net::UnixListener {
type Conn = mio_1xx::net::UnixStream;

fn bind_unix_addr(on: &UnixSocketAddr) -> Result<Self, io::Error> {
let socket = Socket::new(SOCK_STREAM, true)?;
Expand Down Expand Up @@ -303,9 +303,9 @@ pub trait UnixDatagramExt: AsRawFd + FromRawFd {
///
/// Read content into a separate buffer than header:
///
#[cfg_attr(feature="mio_08", doc="```")]
#[cfg_attr(not(feature="mio_08"), doc="```no_compile")]
/// use mio_08::net::UnixDatagram;
#[cfg_attr(feature="mio_1xx", doc="```")]
#[cfg_attr(not(feature="mio_1xx"), doc="```no_compile")]
/// use mio_1xx::net::UnixDatagram;
/// use uds::UnixDatagramExt;
/// use std::io::IoSliceMut;
///
Expand Down Expand Up @@ -497,10 +497,10 @@ impl UnixDatagramExt for UnixDatagram {
}
}

#[cfg(feature = "mio_08")]
impl UnixDatagramExt for mio_08::net::UnixDatagram {
#[cfg(feature = "mio_1xx")]
impl UnixDatagramExt for mio_1xx::net::UnixDatagram {
fn bind_unix_addr(addr: &UnixSocketAddr) -> Result<Self, io::Error> {
match mio_08::net::UnixDatagram::unbound() {
match mio_1xx::net::UnixDatagram::unbound() {
Ok(socket) => match socket.bind_to_unix_addr(addr) {
Ok(()) => Ok(socket),
Err(e) => Err(e),
Expand Down
12 changes: 6 additions & 6 deletions tests/mio.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![cfg(any(feature = "mio_08"))]
#![cfg(any(feature = "mio_1xx"))]

#[cfg(feature = "mio_08")]
extern crate mio_08;
#[cfg(feature = "mio_1xx")]
extern crate mio_1xx;

use std::fs::remove_file;
use std::{io::{Read, Write}, path::Path, time::Duration};
Expand Down Expand Up @@ -63,8 +63,8 @@ macro_rules! mio_streams {
}
}

#[cfg(feature = "mio_08")]
#[cfg(feature = "mio_1xx")]
#[test]
fn mio_08_stream() {
mio_streams!(mio_08);
fn mio_1xx_stream() {
mio_streams!(mio_1xx);
}
2 changes: 1 addition & 1 deletion tests/test_locally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ done
echo "checking with minimum version dependencies"
rm Cargo.lock
cargo +nightly check $CAFLAGS -Z minimal-versions
cargo +nightly check $CAFLAGS -Z minimal-versions --features mio_08
cargo +nightly check $CAFLAGS -Z minimal-versions --features mio_1xx
cargo +nightly check $CAFLAGS -Z minimal-versions --all-features
rm Cargo.lock
echo
Expand Down