1 use netio::bytes_errors::{BytesReadError, BytesWriteError}; 2 3 use std::time::SystemTimeError; 4 5 pub enum HandshakeErrorValue { 6 BytesReadError(BytesReadError), 7 BytesWriteError(BytesWriteError), 8 SysTimeError(SystemTimeError), 9 DigestNotFound, 10 S0VersionNotCorrect, 11 } 12 13 pub struct HandshakeError { 14 pub value: HandshakeErrorValue, 15 } 16 17 impl From<HandshakeErrorValue> for HandshakeError { 18 fn from(val: HandshakeErrorValue) -> Self { 19 HandshakeError { value: val } 20 } 21 } 22 23 impl From<BytesReadError> for HandshakeError { 24 fn from(error: BytesReadError) -> Self { 25 HandshakeError { 26 value: HandshakeErrorValue::BytesReadError(error), 27 } 28 } 29 } 30 31 impl From<BytesWriteError> for HandshakeError { 32 fn from(error: BytesWriteError) -> Self { 33 HandshakeError { 34 value: HandshakeErrorValue::BytesWriteError(error), 35 } 36 } 37 } 38 39 impl From<SystemTimeError> for HandshakeError { 40 fn from(error: SystemTimeError) -> Self { 41 HandshakeError { 42 value: HandshakeErrorValue::SysTimeError(error), 43 } 44 } 45 } 46