fn write_msg<W>(
		&self,
		rx: UnboundedReceiver<Vec<u8>>,
		writer: W,
	) -> Box<Future<Item = W, Error = Error>>
	where
		W: AsyncWrite + 'static,
	{
		let sent_bytes = self.sent_bytes.clone();
		let send_data = rx
			.map_err(|_| Error::ConnectionClose)
			.map(move |data| {
				trace!(LOGGER, "write_msg: start");
				// add the count of bytes sent
				let mut sent_bytes = sent_bytes.lock().unwrap();
				*sent_bytes += data.len() as u64;
				data
			})
			// write the data and make sure the future returns the right types
			.fold(writer, |writer, data| {
				write_all(writer, data).map_err(|e| Error::Connection(e)).map(|(writer, _)| {
					trace!(LOGGER, "write_msg: done");
					writer
				})
			});
		Box::new(send_data)
	}
/// Prepares the future that gets message data produced by our system and
/// sends it to the peer connection
Prepares the future that gets message data produced by our system and
sends it to the peer connection
Prepares the future that gets message data produced by our system and sends it to the peer connection
fn write_msg<W>(
		&self,
		rx: UnboundedReceiver<Vec<u8>>,
		writer: W,
	) -> Box<Future<Item = W, Error = Error>>
	where
		W: AsyncWrite + 'static,
	{
		let sent_bytes = self.sent_bytes.clone();
		let send_data = rx
			.map_err(|_| Error::ConnectionClose)
			.map(move |data| {
				trace!(LOGGER, "write_msg: start");
				// add the count of bytes sent
				let mut sent_bytes = sent_bytes.lock().unwrap();
				*sent_bytes += data.len() as u64;
				data
			})
			// write the data and make sure the future returns the right types
			.fold(writer, |writer, data| {
				write_all(writer, data).map_err(|e| Error::Connection(e)).map(|(writer, _)| {
					trace!(LOGGER, "write_msg: done");
					writer
				})
			});
		Box::new(send_data)
	}
fn write_msg < W > ( & self , rx : UnboundedReceiver < Vec < u8 > > , writer : W , ) -> Box < Future < Item = W , Error = Error > > where W : AsyncWrite + ' static , { let sent_bytes = self . sent_bytes . clone ( ) ; let send_data = rx . map_err ( | _ | Error :: ConnectionClose ) . map ( move | data | { trace ! ( LOGGER " " ) ; // add the count of bytes sent let mut sent_bytes = sent_bytes . lock ( ) . unwrap ( ) ; * sent_bytes += data . len ( ) as u64 ; data } ) // write the data and make sure the future returns the right types . fold ( writer , | writer , data | { write_all ( writer , data ) . map_err ( | e | Error :: Connection ( e ) ) . map ( | ( writer , _ ) | { trace ! ( LOGGER " " ) ; writer } ) } ) ; Box :: new ( send_data ) }
Prepares the future that gets message data produced by our system and
sends it to the peer connection
Prepares the future that gets message data produced by our system and sends it to the peer connection
&self
rx
UnboundedReceiver<Vec<u8>>
writer
W