-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
305 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
extern crate tokio1_crate as tokio; | ||
use auto_enums::enum_derive; | ||
enum Enum<A, B> { | ||
A(A), | ||
B(B), | ||
} | ||
#[allow(unsafe_code)] | ||
impl<A, B> ::tokio::io::AsyncBufRead for Enum<A, B> | ||
where | ||
A: ::tokio::io::AsyncBufRead, | ||
B: ::tokio::io::AsyncBufRead, | ||
{ | ||
fn poll_fill_buf<'__a>( | ||
self: ::core::pin::Pin<&'__a mut Self>, | ||
cx: &mut ::core::task::Context<'_>, | ||
) -> ::core::task::Poll<::std::io::Result<&'__a [u8]>> { | ||
unsafe { | ||
match self.get_unchecked_mut() { | ||
Enum::A(x) => { | ||
::tokio::io::AsyncBufRead::poll_fill_buf( | ||
::core::pin::Pin::new_unchecked(x), | ||
cx, | ||
) | ||
} | ||
Enum::B(x) => { | ||
::tokio::io::AsyncBufRead::poll_fill_buf( | ||
::core::pin::Pin::new_unchecked(x), | ||
cx, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
fn consume(self: ::core::pin::Pin<&mut Self>, amt: usize) { | ||
unsafe { | ||
match self.get_unchecked_mut() { | ||
Enum::A(x) => { | ||
::tokio::io::AsyncBufRead::consume( | ||
::core::pin::Pin::new_unchecked(x), | ||
amt, | ||
) | ||
} | ||
Enum::B(x) => { | ||
::tokio::io::AsyncBufRead::consume( | ||
::core::pin::Pin::new_unchecked(x), | ||
amt, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
extern crate tokio1_crate as tokio; | ||
|
||
use auto_enums::enum_derive; | ||
|
||
#[enum_derive(tokio1::AsyncBufRead)] | ||
enum Enum<A, B> { | ||
A(A), | ||
B(B), | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
extern crate tokio1_crate as tokio; | ||
use auto_enums::enum_derive; | ||
enum Enum<A, B> { | ||
A(A), | ||
B(B), | ||
} | ||
#[allow(unsafe_code)] | ||
impl<A, B> ::tokio::io::AsyncRead for Enum<A, B> | ||
where | ||
A: ::tokio::io::AsyncRead, | ||
B: ::tokio::io::AsyncRead, | ||
{ | ||
fn poll_read( | ||
self: ::core::pin::Pin<&mut Self>, | ||
cx: &mut ::core::task::Context<'_>, | ||
buf: &mut ::tokio::io::ReadBuf<'_>, | ||
) -> ::core::task::Poll<::std::io::Result<()>> { | ||
unsafe { | ||
match self.get_unchecked_mut() { | ||
Enum::A(x) => { | ||
::tokio::io::AsyncRead::poll_read( | ||
::core::pin::Pin::new_unchecked(x), | ||
cx, | ||
buf, | ||
) | ||
} | ||
Enum::B(x) => { | ||
::tokio::io::AsyncRead::poll_read( | ||
::core::pin::Pin::new_unchecked(x), | ||
cx, | ||
buf, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
extern crate tokio1_crate as tokio; | ||
|
||
use auto_enums::enum_derive; | ||
|
||
#[enum_derive(tokio1::AsyncRead)] | ||
enum Enum<A, B> { | ||
A(A), | ||
B(B), | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
extern crate tokio1_crate as tokio; | ||
use auto_enums::enum_derive; | ||
enum Enum<A, B> { | ||
A(A), | ||
B(B), | ||
} | ||
#[allow(unsafe_code)] | ||
impl<A, B> ::tokio::io::AsyncSeek for Enum<A, B> | ||
where | ||
A: ::tokio::io::AsyncSeek, | ||
B: ::tokio::io::AsyncSeek, | ||
{ | ||
fn start_seek( | ||
self: ::core::pin::Pin<&mut Self>, | ||
pos: ::std::io::SeekFrom, | ||
) -> ::std::io::Result<()> { | ||
unsafe { | ||
match self.get_unchecked_mut() { | ||
Enum::A(x) => { | ||
::tokio::io::AsyncSeek::start_seek( | ||
::core::pin::Pin::new_unchecked(x), | ||
pos, | ||
) | ||
} | ||
Enum::B(x) => { | ||
::tokio::io::AsyncSeek::start_seek( | ||
::core::pin::Pin::new_unchecked(x), | ||
pos, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
fn poll_complete( | ||
self: ::core::pin::Pin<&mut Self>, | ||
cx: &mut ::core::task::Context<'_>, | ||
) -> ::core::task::Poll<::std::io::Result<u64>> { | ||
unsafe { | ||
match self.get_unchecked_mut() { | ||
Enum::A(x) => { | ||
::tokio::io::AsyncSeek::poll_complete( | ||
::core::pin::Pin::new_unchecked(x), | ||
cx, | ||
) | ||
} | ||
Enum::B(x) => { | ||
::tokio::io::AsyncSeek::poll_complete( | ||
::core::pin::Pin::new_unchecked(x), | ||
cx, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
extern crate tokio1_crate as tokio; | ||
|
||
use auto_enums::enum_derive; | ||
|
||
#[enum_derive(tokio1::AsyncSeek)] | ||
enum Enum<A, B> { | ||
A(A), | ||
B(B), | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
extern crate tokio1_crate as tokio; | ||
use auto_enums::enum_derive; | ||
enum Enum<A, B> { | ||
A(A), | ||
B(B), | ||
} | ||
#[allow(unsafe_code)] | ||
impl<A, B> ::tokio::io::AsyncWrite for Enum<A, B> | ||
where | ||
A: ::tokio::io::AsyncWrite, | ||
B: ::tokio::io::AsyncWrite, | ||
{ | ||
fn poll_write( | ||
self: ::core::pin::Pin<&mut Self>, | ||
cx: &mut ::core::task::Context<'_>, | ||
buf: &[u8], | ||
) -> ::core::task::Poll<::std::io::Result<usize>> { | ||
unsafe { | ||
match self.get_unchecked_mut() { | ||
Enum::A(x) => { | ||
::tokio::io::AsyncWrite::poll_write( | ||
::core::pin::Pin::new_unchecked(x), | ||
cx, | ||
buf, | ||
) | ||
} | ||
Enum::B(x) => { | ||
::tokio::io::AsyncWrite::poll_write( | ||
::core::pin::Pin::new_unchecked(x), | ||
cx, | ||
buf, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
fn poll_flush( | ||
self: ::core::pin::Pin<&mut Self>, | ||
cx: &mut ::core::task::Context<'_>, | ||
) -> ::core::task::Poll<::std::io::Result<()>> { | ||
unsafe { | ||
match self.get_unchecked_mut() { | ||
Enum::A(x) => { | ||
::tokio::io::AsyncWrite::poll_flush( | ||
::core::pin::Pin::new_unchecked(x), | ||
cx, | ||
) | ||
} | ||
Enum::B(x) => { | ||
::tokio::io::AsyncWrite::poll_flush( | ||
::core::pin::Pin::new_unchecked(x), | ||
cx, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
fn poll_shutdown( | ||
self: ::core::pin::Pin<&mut Self>, | ||
cx: &mut ::core::task::Context<'_>, | ||
) -> ::core::task::Poll<::std::io::Result<()>> { | ||
unsafe { | ||
match self.get_unchecked_mut() { | ||
Enum::A(x) => { | ||
::tokio::io::AsyncWrite::poll_shutdown( | ||
::core::pin::Pin::new_unchecked(x), | ||
cx, | ||
) | ||
} | ||
Enum::B(x) => { | ||
::tokio::io::AsyncWrite::poll_shutdown( | ||
::core::pin::Pin::new_unchecked(x), | ||
cx, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
fn poll_write_vectored( | ||
self: ::core::pin::Pin<&mut Self>, | ||
cx: &mut ::core::task::Context<'_>, | ||
bufs: &[::std::io::IoSlice<'_>], | ||
) -> ::core::task::Poll<::std::io::Result<usize>> { | ||
unsafe { | ||
match self.get_unchecked_mut() { | ||
Enum::A(x) => { | ||
::tokio::io::AsyncWrite::poll_write_vectored( | ||
::core::pin::Pin::new_unchecked(x), | ||
cx, | ||
bufs, | ||
) | ||
} | ||
Enum::B(x) => { | ||
::tokio::io::AsyncWrite::poll_write_vectored( | ||
::core::pin::Pin::new_unchecked(x), | ||
cx, | ||
bufs, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
fn is_write_vectored(&self) -> bool { | ||
match self { | ||
Enum::A(x) => ::tokio::io::AsyncWrite::is_write_vectored(x), | ||
Enum::B(x) => ::tokio::io::AsyncWrite::is_write_vectored(x), | ||
} | ||
} | ||
} | ||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
extern crate tokio1_crate as tokio; | ||
|
||
use auto_enums::enum_derive; | ||
|
||
#[enum_derive(tokio1::AsyncWrite)] | ||
enum Enum<A, B> { | ||
A(A), | ||
B(B), | ||
} | ||
|
||
fn main() {} |