Add deadline case to the io Error type
The Error
type in std::io
defines the case TimedOut
for IO timeouts. When working with operations that can time out, you might want to retry the operation a few times. If deadlines are supported, you don't want to retry the operation if the deadline expires, as that could lead to you extending the deadline by waiting after a retry.
Or to put it another way: you do want to retry a sporadic network timeout, but you don't want to retry the deadline.
Currently you can't tell the two apart, as expired deadlines are treated as regular timeouts. Instead we should extend the runtime and standard library to support a DeadlineExceeded
case, which is only produced when deadlines are, well, exceeded. Using this you can implement a retry mechanism that does retry regular timeouts, but not deadline expirations.