Understanding OS-Backed Event Queues, System Calls, and Cross-Platform Abstractions 60 msg_ptr, len, &mut output, std::ptr::null() )}; if res == 0 { return Err(io::Error::last_os_error()); } Ok(()) } The first thing we do is convert the text to utf-16-encoded text, which Windows uses. Fortunately, Rust has a built-in function to convert our utf-8-encoded text to utf-16 code points. encode_ utf16 returns an iterator over u16 code points that we can collect to a Vec. The next two lines should be familiar by now. We get the pointer to where the text is stored and the length of the text in bytes. The next thing we do is call Get Std Handle and pass in the value-11. The values we need to pass in for the different standard devices are described together with the Get Std Handle documentation at https://learn. microsoft. com/en-us/windows/console/getstdhandle. This is convenient, as we don't have to dig through C header files to find all the constant values we need. The return code to expect is also documented thoroughly for all functions, so we handle potential errors here in the same way as we did for the Linux/mac OS syscalls. Finally, we have the call to the Write Console W function. There is nothing too fancy about this, and you'll notice similarities with the write syscall we used for Linux. One difference is that the output is not returned from the function but written to an address location we pass in in the form of a pointer to our output variable. Note Now that you've seen how we create cross-platform syscalls, you will probably also understand why we're not including the code to make every example in this book cross-platform. It's simply the case that the book would be extremely long if we did, and it's not apparent that all that extra information will actually benefit our understanding of the key concepts.