diff options
author | Alex Auvolat <alex@adnab.me> | 2022-09-01 11:34:53 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-09-01 11:34:53 +0200 |
commit | 745c78618479c4177647e4d7fed97d5fd2d00d4f (patch) | |
tree | 0f1d0dfa4bda8c4ae286ec12d726e03a55d7c2ec /src/error.rs | |
parent | 7909a95d3c02a738c9a088c1cb8a5d6f70b06046 (diff) | |
download | netapp-745c78618479c4177647e4d7fed97d5fd2d00d4f.tar.gz netapp-745c78618479c4177647e4d7fed97d5fd2d00d4f.zip |
Also encode errorkind in stream
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs index f374341..2fa4594 100644 --- a/src/error.rs +++ b/src/error.rs @@ -109,3 +109,39 @@ where } } } + +// ---- Helpers for serializing I/O Errors + +pub(crate) fn u8_to_io_errorkind(v: u8) -> std::io::ErrorKind { + use std::io::ErrorKind; + match v { + 101 => ErrorKind::ConnectionAborted, + 102 => ErrorKind::BrokenPipe, + 103 => ErrorKind::WouldBlock, + 104 => ErrorKind::InvalidInput, + 105 => ErrorKind::InvalidData, + 106 => ErrorKind::TimedOut, + 107 => ErrorKind::Interrupted, + 108 => ErrorKind::UnexpectedEof, + 109 => ErrorKind::OutOfMemory, + 110 => ErrorKind::ConnectionReset, + _ => ErrorKind::Other, + } +} + +pub(crate) fn io_errorkind_to_u8(kind: std::io::ErrorKind) -> u8 { + use std::io::ErrorKind; + match kind { + ErrorKind::ConnectionAborted => 101, + ErrorKind::BrokenPipe => 102, + ErrorKind::WouldBlock => 103, + ErrorKind::InvalidInput => 104, + ErrorKind::InvalidData => 105, + ErrorKind::TimedOut => 106, + ErrorKind::Interrupted => 107, + ErrorKind::UnexpectedEof => 108, + ErrorKind::OutOfMemory => 109, + ErrorKind::ConnectionReset => 110, + _ => 100, + } +} |