-
-
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
7 changed files
with
71 additions
and
1 deletion.
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
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,26 @@ | ||
use proc_macro2::TokenStream; | ||
use quote::quote; | ||
|
||
use crate::utils::*; | ||
|
||
pub(crate) const NAME: &[&str] = &["futures::AsyncRead"]; | ||
|
||
pub(crate) fn derive(data: &Data) -> Result<TokenStream> { | ||
let root = std_root(); | ||
let io = quote!(::futures::io); | ||
|
||
derive_trait!( | ||
data, | ||
parse_quote!(#io::AsyncRead)?, | ||
parse_quote! { | ||
trait AsyncRead { | ||
#[inline] | ||
unsafe fn initializer(&self) -> #io::Initializer; | ||
#[inline] | ||
fn poll_read(&mut self, lw: &#root::task::LocalWaker, buf: &mut [u8]) -> #root::task::Poll<#root::result::Result<usize, #io::Error>>; | ||
#[inline] | ||
fn poll_vectored_read(&mut self, lw: &#root::task::LocalWaker, vec: &mut [&mut #io::IoVec]) -> #root::task::Poll<#root::result::Result<usize, #io::Error>>; | ||
} | ||
}?, | ||
) | ||
} |
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,28 @@ | ||
use proc_macro2::TokenStream; | ||
use quote::quote; | ||
|
||
use crate::utils::*; | ||
|
||
pub(crate) const NAME: &[&str] = &["futures::AsyncWrite"]; | ||
|
||
pub(crate) fn derive(data: &Data) -> Result<TokenStream> { | ||
let root = std_root(); | ||
let io = quote!(::futures::io); | ||
|
||
derive_trait!( | ||
data, | ||
parse_quote!(#io::AsyncWrite)?, | ||
parse_quote! { | ||
trait AsyncWrite { | ||
#[inline] | ||
fn poll_write(&mut self, lw: &#root::task::LocalWaker, buf: &[u8]) -> #root::task::Poll<#root::result::Result<usize, #io::Error>>; | ||
#[inline] | ||
fn poll_vectored_write(&mut self, lw: &#root::task::LocalWaker, vec: &[&#io::IoVec]) -> #root::task::Poll<#root::result::Result<usize, #io::Error>>; | ||
#[inline] | ||
fn poll_flush(&mut self, lw: &#root::task::LocalWaker) -> #root::task::Poll<#root::result::Result<(), #io::Error>>; | ||
#[inline] | ||
fn poll_close(&mut self, lw: &#root::task::LocalWaker) -> #root::task::Poll<#root::result::Result<(), #io::Error>>; | ||
} | ||
}?, | ||
) | ||
} |
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
pub(crate) mod async_read; | ||
pub(crate) mod async_write; | ||
pub(crate) mod sink; | ||
pub(crate) mod stream; |
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