The Poll module 81 Now that we've covered the hard part of this chapter and gotten a high-level overview of how epoll works, it's time to implement our mio-inspired API in poll. rs. The Poll module If you haven't written or copied the code we presented in the Design and introduction to epoll section, it's time to do it now. We'll implement all the functions where we just had todo!() earlier. We start by implementing the methods on our Poll struct. First up is opening the impl Poll block and implementing the new function: ch04/a-epoll/src/poll. rs impl Poll { pub fn new()-> Result<Self> { let res = unsafe { ffi::epoll_create(1) }; if res < 0 { return Err(io::Error::last_os_error()); } Ok(Self { registry: Registry { raw_fd: res }, }) } Given the thorough introduction to epoll in the The ffi module section, this should be pretty straightforward. We call ffi::epoll_create with an argument of 1 (remember, the argument is ignored but must have a non-zero value). If we get any errors, we ask the operating system to report the last error for our process and return that. If the call succeeds, we return a new Poll instance that simply wraps around our registry that holds the epoll file descriptor. Next up is our registry method, which simply hands out a reference to the inner Registry struct: ch04/a-epoll/src/poll. rs pub fn registry(&self)-> &Registry { &self. registry }