Skip to content

Commit db04cb2

Browse files
authored
fix: change type alias restriction to satisfy latest nightly (#89)
1 parent 06327eb commit db04cb2

14 files changed

+85
-82
lines changed

deny.toml

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
[licenses]
2-
unlicensed = "deny"
32
allow = [
4-
"MIT",
5-
"Apache-2.0",
6-
"Apache-2.0 WITH LLVM-exception",
7-
"Zlib",
8-
"BSD-3-Clause",
9-
"Unlicense"
3+
"MIT",
4+
"Apache-2.0",
5+
"Apache-2.0 WITH LLVM-exception",
6+
"Zlib",
7+
"BSD-3-Clause",
8+
"Unlicense",
9+
"Unicode-DFS-2016",
1010
]
11+
confidence-threshold = 0.95
1112
copyleft = "deny"
1213
default = "deny"
13-
confidence-threshold = 0.95
14-
private = { ignore = true }
14+
private = {ignore = true}
15+
unlicensed = "deny"
1516

1617
[advisories]
17-
vulnerability = "deny"
18-
unmaintained = "deny"
1918
notice = "deny"
19+
unmaintained = "deny"
2020
unsound = "deny"
21+
vulnerability = "deny"
2122

2223
[bans]
23-
multiple-versions = "allow"
24+
multiple-versions = "allow"

monoio/src/io/async_read_rent.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ pub trait AsyncReadRent {
1010
type ReadFuture<'a, T>: Future<Output = BufResult<usize, T>>
1111
where
1212
Self: 'a,
13-
T: 'a;
13+
T: IoBufMut + 'a;
1414
/// The future of readv Result<size, buffer>
1515
type ReadvFuture<'a, T>: Future<Output = BufResult<usize, T>>
1616
where
1717
Self: 'a,
18-
T: 'a;
18+
T: IoVecBufMut + 'a;
1919

2020
/// Same as read(2)
2121
fn read<T: IoBufMut>(&mut self, buf: T) -> Self::ReadFuture<'_, T>;
@@ -39,12 +39,12 @@ impl<A: ?Sized + AsyncReadRent> AsyncReadRent for &mut A {
3939
type ReadFuture<'a, T> = A::ReadFuture<'a, T>
4040
where
4141
Self: 'a,
42-
T: 'a;
42+
T: IoBufMut + 'a;
4343

4444
type ReadvFuture<'a, T> = A::ReadvFuture<'a, T>
4545
where
4646
Self: 'a,
47-
T: 'a;
47+
T: IoVecBufMut + 'a;
4848

4949
fn read<T: IoBufMut>(&mut self, buf: T) -> Self::ReadFuture<'_, T> {
5050
(**self).read(buf)
@@ -57,9 +57,9 @@ impl<A: ?Sized + AsyncReadRent> AsyncReadRent for &mut A {
5757

5858
impl AsyncReadRent for &[u8] {
5959
type ReadFuture<'a, B> = impl std::future::Future<Output = crate::BufResult<usize, B>> where
60-
B: 'a, Self: 'a;
60+
B: IoBufMut + 'a, Self: 'a;
6161
type ReadvFuture<'a, B> = impl std::future::Future<Output = crate::BufResult<usize, B>> where
62-
B: 'a, Self: 'a;
62+
B: IoVecBufMut + 'a, Self: 'a;
6363

6464
fn read<T: IoBufMut>(&mut self, mut buf: T) -> Self::ReadFuture<'_, T> {
6565
let amt = std::cmp::min(self.len(), buf.bytes_total());

monoio/src/io/async_read_rent_ext.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub trait AsyncReadRentExt {
5151
type ReadExactFuture<'a, T>: Future<Output = BufResult<usize, T>>
5252
where
5353
Self: 'a,
54-
T: 'a;
54+
T: IoBufMut + 'a;
5555

5656
/// Read until buf capacity is fulfilled
5757
fn read_exact<T: 'static>(&mut self, buf: T) -> Self::ReadExactFuture<'_, T>
@@ -62,7 +62,7 @@ pub trait AsyncReadRentExt {
6262
type ReadVectoredExactFuture<'a, T>: Future<Output = BufResult<usize, T>>
6363
where
6464
Self: 'a,
65-
T: 'a;
65+
T: IoVecBufMut + 'a;
6666

6767
/// Readv until buf capacity is fulfilled
6868
fn read_vectored_exact<T: 'static>(&mut self, buf: T) -> Self::ReadVectoredExactFuture<'_, T>
@@ -100,7 +100,7 @@ impl<A> AsyncReadRentExt for A
100100
where
101101
A: AsyncReadRent + ?Sized,
102102
{
103-
type ReadExactFuture<'a, T> = impl Future<Output = BufResult<usize, T>> where A: 'a, T: 'a;
103+
type ReadExactFuture<'a, T> = impl Future<Output = BufResult<usize, T>> where A: 'a, T: IoBufMut + 'a;
104104

105105
fn read_exact<T>(&mut self, mut buf: T) -> Self::ReadExactFuture<'_, T>
106106
where
@@ -135,7 +135,7 @@ where
135135
}
136136
}
137137

138-
type ReadVectoredExactFuture<'a, T> = impl Future<Output = BufResult<usize, T>> where A: 'a, T: 'a;
138+
type ReadVectoredExactFuture<'a, T> = impl Future<Output = BufResult<usize, T>> where A: 'a, T: IoVecBufMut + 'a;
139139

140140
fn read_vectored_exact<T: 'static>(
141141
&mut self,

monoio/src/io/async_write_rent.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ pub trait AsyncWriteRent {
1010
type WriteFuture<'a, T>: Future<Output = BufResult<usize, T>>
1111
where
1212
Self: 'a,
13-
T: 'a;
13+
T: IoBuf + 'a;
1414
/// The future of writev Result<size, buffer>
1515
type WritevFuture<'a, T>: Future<Output = BufResult<usize, T>>
1616
where
1717
Self: 'a,
18-
T: 'a;
18+
T: IoVecBuf + 'a;
1919

2020
/// The future of flush
2121
type FlushFuture<'a>: Future<Output = std::io::Result<()>>
@@ -56,12 +56,12 @@ impl<A: ?Sized + AsyncWriteRent> AsyncWriteRent for &mut A {
5656
type WriteFuture<'a, T> = A::WriteFuture<'a, T>
5757
where
5858
Self: 'a,
59-
T: 'a;
59+
T: IoBuf + 'a;
6060

6161
type WritevFuture<'a, T> = A::WritevFuture<'a, T>
6262
where
6363
Self: 'a,
64-
T: 'a;
64+
T: IoVecBuf + 'a;
6565

6666
type FlushFuture<'a> = A::FlushFuture<'a>
6767
where

monoio/src/io/async_write_rent_ext.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub trait AsyncWriteRentExt {
1111
type WriteExactFuture<'a, T>: Future<Output = BufResult<usize, T>>
1212
where
1313
Self: 'a,
14-
T: 'a;
14+
T: IoBuf + 'a;
1515

1616
/// Write all
1717
fn write_all<T>(&mut self, buf: T) -> Self::WriteExactFuture<'_, T>
@@ -22,7 +22,7 @@ pub trait AsyncWriteRentExt {
2222
type WriteVectoredExactFuture<'a, T>: Future<Output = BufResult<usize, T>>
2323
where
2424
Self: 'a,
25-
T: 'a;
25+
T: IoVecBuf + 'a;
2626

2727
/// Write all
2828
fn write_vectored_all<T>(&mut self, buf: T) -> Self::WriteVectoredExactFuture<'_, T>
@@ -34,7 +34,7 @@ impl<A> AsyncWriteRentExt for A
3434
where
3535
A: AsyncWriteRent + ?Sized,
3636
{
37-
type WriteExactFuture<'a, T> = impl Future<Output = BufResult<usize, T>> where A: 'a, T: 'a;
37+
type WriteExactFuture<'a, T> = impl Future<Output = BufResult<usize, T>> where A: 'a, T: IoBuf + 'a;
3838

3939
fn write_all<T>(&mut self, mut buf: T) -> Self::WriteExactFuture<'_, T>
4040
where
@@ -66,7 +66,7 @@ where
6666
}
6767
}
6868

69-
type WriteVectoredExactFuture<'a, T> = impl Future<Output = BufResult<usize, T>> where A: 'a, T: 'a;
69+
type WriteVectoredExactFuture<'a, T> = impl Future<Output = BufResult<usize, T>> where A: 'a, T: IoVecBuf + 'a;
7070

7171
fn write_vectored_all<T>(&mut self, buf: T) -> Self::WriteVectoredExactFuture<'_, T>
7272
where

monoio/src/io/stream/stream_ext.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ pub trait StreamExt: Stream {
4141

4242
impl<T> StreamExt for T where T: Stream {}
4343

44-
type ForEachFut<T: Stream, Fut, F> = impl Future<Output = ()>;
44+
type ForEachFut<T: Stream, Fut: Future<Output = ()>, F: FnMut(<T as Stream>::Item) -> Fut> =
45+
impl Future<Output = ()>;
4546

4647
#[must_use = "streams do nothing unless polled"]
4748
pub struct Map<St, F> {

monoio/src/io/util/buf_reader.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{
2-
buf::IoVecWrapperMut,
2+
buf::{IoBuf, IoBufMut, IoVecBuf, IoVecBufMut, IoVecWrapperMut},
33
io::{AsyncBufRead, AsyncReadRent, AsyncWriteRent},
44
};
55
use std::future::Future;
@@ -69,12 +69,12 @@ impl<R> BufReader<R> {
6969

7070
impl<R: AsyncReadRent> AsyncReadRent for BufReader<R> {
7171
type ReadFuture<'a, T> = impl Future<Output = crate::BufResult<usize, T>> where
72-
T: 'a, R: 'a;
72+
T: IoBufMut + 'a, R: 'a;
7373

7474
type ReadvFuture<'a, T> = impl Future<Output = crate::BufResult<usize, T>> where
75-
T: 'a, R: 'a;
75+
T: IoVecBufMut + 'a, R: 'a;
7676

77-
fn read<T: crate::buf::IoBufMut>(&mut self, mut buf: T) -> Self::ReadFuture<'_, T> {
77+
fn read<T: IoBufMut>(&mut self, mut buf: T) -> Self::ReadFuture<'_, T> {
7878
async move {
7979
// If we don't have any buffered data and we're doing a massive read
8080
// (larger than our internal buffer), bypass our internal buffer
@@ -101,7 +101,7 @@ impl<R: AsyncReadRent> AsyncReadRent for BufReader<R> {
101101
}
102102
}
103103

104-
fn readv<T: crate::buf::IoVecBufMut>(&mut self, mut buf: T) -> Self::ReadvFuture<'_, T> {
104+
fn readv<T: IoVecBufMut>(&mut self, mut buf: T) -> Self::ReadvFuture<'_, T> {
105105
async move {
106106
let slice = match IoVecWrapperMut::new(buf) {
107107
Ok(slice) => slice,
@@ -160,20 +160,20 @@ impl<R: AsyncReadRent> AsyncBufRead for BufReader<R> {
160160

161161
impl<R: AsyncReadRent + AsyncWriteRent> AsyncWriteRent for BufReader<R> {
162162
type WriteFuture<'a, T> = R::WriteFuture<'a, T> where
163-
T: 'a, R: 'a;
163+
T: IoBuf + 'a, R: 'a;
164164

165165
type WritevFuture<'a, T>= R::WritevFuture<'a, T> where
166-
T: 'a, R: 'a;
166+
T: IoVecBuf + 'a, R: 'a;
167167

168168
type FlushFuture<'a> = R::FlushFuture<'a> where R: 'a;
169169

170170
type ShutdownFuture<'a> = R::ShutdownFuture<'a> where R: 'a;
171171

172-
fn write<T: crate::buf::IoBuf>(&mut self, buf: T) -> Self::WriteFuture<'_, T> {
172+
fn write<T: IoBuf>(&mut self, buf: T) -> Self::WriteFuture<'_, T> {
173173
self.inner.write(buf)
174174
}
175175

176-
fn writev<T: crate::buf::IoVecBuf>(&mut self, buf_vec: T) -> Self::WritevFuture<'_, T> {
176+
fn writev<T: IoVecBuf>(&mut self, buf_vec: T) -> Self::WritevFuture<'_, T> {
177177
self.inner.writev(buf_vec)
178178
}
179179

monoio/src/io/util/buf_writer.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{future::Future, io};
22

33
use crate::{
4-
buf::{IoVecWrapper, Slice},
4+
buf::{IoBuf, IoBufMut, IoVecBuf, IoVecBufMut, IoVecWrapper, Slice},
55
io::{AsyncBufRead, AsyncReadRent, AsyncWriteRent, AsyncWriteRentExt},
66
};
77

@@ -85,18 +85,18 @@ impl<W: AsyncWriteRent> BufWriter<W> {
8585

8686
impl<W: AsyncWriteRent> AsyncWriteRent for BufWriter<W> {
8787
type WriteFuture<'a, T> = impl Future<Output = crate::BufResult<usize, T>> where
88-
T: 'a, W: 'a;
88+
T: IoBuf + 'a, W: 'a;
8989

9090
type WritevFuture<'a, T> = impl Future<Output = crate::BufResult<usize, T>> where
91-
T: 'a, W: 'a;
91+
T: IoVecBuf + 'a, W: 'a;
9292

9393
type FlushFuture<'a> = impl Future<Output = io::Result<()>> where
9494
W: 'a;
9595

9696
type ShutdownFuture<'a> = impl Future<Output = io::Result<()>> where
9797
W: 'a;
9898

99-
fn write<T: crate::buf::IoBuf>(&mut self, buf: T) -> Self::WriteFuture<'_, T> {
99+
fn write<T: IoBuf>(&mut self, buf: T) -> Self::WriteFuture<'_, T> {
100100
async move {
101101
let owned_buf = self.buf.as_ref().unwrap();
102102
let owned_len = owned_buf.len();
@@ -136,7 +136,7 @@ impl<W: AsyncWriteRent> AsyncWriteRent for BufWriter<W> {
136136
}
137137

138138
// TODO: implement it as real io_vec
139-
fn writev<T: crate::buf::IoVecBuf>(&mut self, buf: T) -> Self::WritevFuture<'_, T> {
139+
fn writev<T: IoVecBuf>(&mut self, buf: T) -> Self::WritevFuture<'_, T> {
140140
async move {
141141
let slice = match IoVecWrapper::new(buf) {
142142
Ok(slice) => slice,
@@ -165,16 +165,16 @@ impl<W: AsyncWriteRent> AsyncWriteRent for BufWriter<W> {
165165

166166
impl<W: AsyncWriteRent + AsyncReadRent> AsyncReadRent for BufWriter<W> {
167167
type ReadFuture<'a, T> = W::ReadFuture<'a, T> where
168-
T: 'a, W: 'a;
168+
T: IoBufMut + 'a, W: 'a;
169169

170170
type ReadvFuture<'a, T> = W::ReadvFuture<'a, T> where
171-
T: 'a, W: 'a;
171+
T: IoVecBufMut + 'a, W: 'a;
172172

173-
fn read<T: crate::buf::IoBufMut>(&mut self, buf: T) -> Self::ReadFuture<'_, T> {
173+
fn read<T: IoBufMut>(&mut self, buf: T) -> Self::ReadFuture<'_, T> {
174174
self.inner.read(buf)
175175
}
176176

177-
fn readv<T: crate::buf::IoVecBufMut>(&mut self, buf: T) -> Self::ReadvFuture<'_, T> {
177+
fn readv<T: IoVecBufMut>(&mut self, buf: T) -> Self::ReadvFuture<'_, T> {
178178
self.inner.readv(buf)
179179
}
180180
}

monoio/src/io/util/prefixed_io.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{
2-
buf::IoVecWrapperMut,
2+
buf::{IoBuf, IoBufMut, IoVecBuf, IoVecBufMut, IoVecWrapperMut},
33
io::{AsyncReadRent, AsyncWriteRent},
44
};
55

@@ -35,13 +35,13 @@ impl<I, P> PrefixedReadIo<I, P> {
3535
impl<I: AsyncReadRent, P: std::io::Read> AsyncReadRent for PrefixedReadIo<I, P> {
3636
type ReadFuture<'a, T> = impl std::future::Future<Output = crate::BufResult<usize, T>>
3737
where
38-
T: 'a, Self: 'a;
38+
T: IoBufMut + 'a, Self: 'a;
3939

4040
type ReadvFuture<'a, T> = impl std::future::Future<Output = crate::BufResult<usize, T>>
4141
where
42-
T: 'a, Self: 'a;
42+
T: IoVecBufMut + 'a, Self: 'a;
4343

44-
fn read<T: crate::buf::IoBufMut>(&mut self, mut buf: T) -> Self::ReadFuture<'_, T> {
44+
fn read<T: IoBufMut>(&mut self, mut buf: T) -> Self::ReadFuture<'_, T> {
4545
async move {
4646
if buf.bytes_total() == 0 {
4747
return (Ok(0), buf);
@@ -69,7 +69,7 @@ impl<I: AsyncReadRent, P: std::io::Read> AsyncReadRent for PrefixedReadIo<I, P>
6969
}
7070
}
7171

72-
fn readv<T: crate::buf::IoVecBufMut>(&mut self, mut buf: T) -> Self::ReadvFuture<'_, T> {
72+
fn readv<T: IoVecBufMut>(&mut self, mut buf: T) -> Self::ReadvFuture<'_, T> {
7373
async move {
7474
let slice = match IoVecWrapperMut::new(buf) {
7575
Ok(slice) => slice,
@@ -88,20 +88,20 @@ impl<I: AsyncReadRent, P: std::io::Read> AsyncReadRent for PrefixedReadIo<I, P>
8888

8989
impl<I: AsyncWriteRent, P> AsyncWriteRent for PrefixedReadIo<I, P> {
9090
type WriteFuture<'a, T> = I::WriteFuture<'a, T> where
91-
T: 'a, Self: 'a;
91+
T: IoBuf + 'a, Self: 'a;
9292

9393
type WritevFuture<'a, T>= I::WritevFuture<'a, T> where
94-
T: 'a, Self: 'a;
94+
T: IoVecBuf + 'a, Self: 'a;
9595

9696
type FlushFuture<'a> = I::FlushFuture<'a> where Self: 'a;
9797

9898
type ShutdownFuture<'a> = I::ShutdownFuture<'a> where Self: 'a;
9999

100-
fn write<T: crate::buf::IoBuf>(&mut self, buf: T) -> Self::WriteFuture<'_, T> {
100+
fn write<T: IoBuf>(&mut self, buf: T) -> Self::WriteFuture<'_, T> {
101101
self.io.write(buf)
102102
}
103103

104-
fn writev<T: crate::buf::IoVecBuf>(&mut self, buf_vec: T) -> Self::WritevFuture<'_, T> {
104+
fn writev<T: IoVecBuf>(&mut self, buf_vec: T) -> Self::WritevFuture<'_, T> {
105105
self.io.writev(buf_vec)
106106
}
107107

monoio/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#![feature(box_into_inner)]
1414
#![feature(new_uninit)]
1515
#![feature(io_error_more)]
16+
#![feature(unboxed_closures)]
1617

1718
#[macro_use]
1819
pub mod macros;

0 commit comments

Comments
 (0)