@@ -86,6 +86,17 @@ pub enum Error {
8686 ReceivedMessageTooLarge ,
8787 /// A message was sent that exceeded the configured length limit
8888 SentMessageTooLarge ,
89+ ChecksumMismatch {
90+ sent_checksum : u64 ,
91+ computed_checksum : u64 ,
92+ } ,
93+ ProtocolVersionMismatch {
94+ our_version : u64 ,
95+ their_version : u64 ,
96+ } ,
97+ ChecksumHandshakeFailed {
98+ checksum_value : u8 ,
99+ } ,
89100 /// A reply wasn't received within the timeout specified
90101 Timeout ,
91102 /// The read half was dropped, crippling the ability to receive replies.
@@ -99,6 +110,9 @@ impl From<async_io_typed::Error> for Error {
99110 async_io_typed:: Error :: Bincode ( e) => Error :: Bincode ( e) ,
100111 async_io_typed:: Error :: ReceivedMessageTooLarge => Error :: ReceivedMessageTooLarge ,
101112 async_io_typed:: Error :: SentMessageTooLarge => Error :: SentMessageTooLarge ,
113+ async_io_typed:: Error :: ChecksumMismatch { sent_checksum, computed_checksum } => Error :: ChecksumMismatch { sent_checksum, computed_checksum } ,
114+ async_io_typed:: Error :: ProtocolVersionMismatch { our_version, their_version } => Error :: ProtocolVersionMismatch { our_version, their_version } ,
115+ async_io_typed:: Error :: ChecksumHandshakeFailed { checksum_value } => Error :: ChecksumHandshakeFailed { checksum_value } ,
102116 }
103117 }
104118}
@@ -111,16 +125,17 @@ pub fn new_duplex_connection_with_limit<
111125 W : AsyncWrite + Unpin ,
112126> (
113127 size_limit : u64 ,
128+ checksums_enabled : bool ,
114129 raw_read : R ,
115130 raw_write : W ,
116131) -> ( AsyncReadConverse < R , W , T > , AsyncWriteConverse < W , T > ) {
117132 let write = Arc :: new ( Mutex :: new ( AsyncWriteTyped :: new_with_limit (
118- raw_write, size_limit,
133+ raw_write, size_limit, checksums_enabled ,
119134 ) ) ) ;
120135 let write_clone = Arc :: clone ( & write) ;
121136 let ( reply_data_sender, reply_data_receiver) = mpsc:: unbounded_channel ( ) ;
122137 let read = AsyncReadConverse {
123- raw : AsyncReadTyped :: new_with_limit ( raw_read, size_limit) ,
138+ raw : AsyncReadTyped :: new_with_limit ( raw_read, size_limit, checksums_enabled ) ,
124139 raw_write : write_clone,
125140 reply_data_receiver,
126141 pending_reply : Vec :: new ( ) ,
@@ -138,10 +153,11 @@ pub fn new_duplex_connection<
138153 R : AsyncRead + Unpin ,
139154 W : AsyncWrite + Unpin ,
140155> (
156+ checksums_enabled : bool ,
141157 raw_read : R ,
142158 raw_write : W ,
143159) -> ( AsyncReadConverse < R , W , T > , AsyncWriteConverse < W , T > ) {
144- new_duplex_connection_with_limit ( 1024u64 . pow ( 2 ) , raw_read, raw_write)
160+ new_duplex_connection_with_limit ( 1024u64 . pow ( 2 ) , checksums_enabled , raw_read, raw_write)
145161}
146162
147163/// Used to receive messages from the connected peer. ***You must drive this in order to receive replies on [AsyncWriteConverse]***
0 commit comments