Struct asyncio::Coroutine
[−]
[src]
pub struct Coroutine<'a>(_);
Context object that represents the currently executing coroutine.
Methods
impl<'a> Coroutine<'a>
[src]
fn wrap<R, E>(&self) -> CoroutineHandler<R, E> where R: Send + 'static, E: Send + 'static
Provides a Coroutine
handler to asynchronous operation.
The CoroutineHandler has trait the Handler
, that type of Handler::Output
is io::Result<R>
.
Examples
use asyncio::{IoContext, AsIoContext, Stream}; use asyncio::ip::{IpProtocol, Tcp, TcpSocket}; let ctx = &IoContext::new().unwrap(); IoContext::spawn(ctx, |coro| { let ctx = coro.as_ctx(); let mut soc = TcpSocket::new(ctx, Tcp::v4()).unwrap(); let mut buf = [0; 256]; let size = soc.async_read_some(&mut buf, coro.wrap()).unwrap(); });