Coroutines and async/await 144 fn write_request(&mut self) { let stream = std::net::Tcp Stream::connect("127. 0. 0. 1:8080"). unwrap(); stream. set_nonblocking(true). unwrap(); let mut stream = mio::net::Tcp Stream::from_std(stream); stream. write_all(get_req(&self. path). as_bytes()). unwrap(); self. stream = Some(stream); } } The impl block defines two functions. The first is new, which simply sets the initial state. The next function is write_requst, which sends the GET request to the server. Y ou've seen this code before in the example in Chapter 4, so this should look familiar. Note When creating Http Get Future, we don't actually do anything related to the GET request, which means that the call to Http::get returns immediately with just a simple data structure. In contrast to earlier examples, we pass in the IP address for localhost instead of the DNS name. We take the same shortcut as before and let connect be blocking and everything else be non-blocking. The next step is to write the GET request to the server. This will be non-blocking, and we don't have to wait for it to finish since we'll be waiting for the response anyway. The last part of this file is the most important one—the implementation of the Future trait we defined: ch07/a-coroutine/src/http. rs impl Future for Http Get Future { type Output = String; fn poll(&mut self)-> Poll State<Self::Output> { if self. stream. is_none() { println!("FIRST POLL-START OPERATION"); self. write_request(); return Poll State::Not Ready; } let mut buff = vec![0u8; 4096]; loop { match self. stream. as_mut(). unwrap(). read(&mut buff) { Ok(0) => {