feat(client): remove Clone requirement for NetworkStream in Client
This commit is contained in:
		
							
								
								
									
										20
									
								
								src/net.rs
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								src/net.rs
									
									
									
									
									
								
							| @@ -53,25 +53,12 @@ impl<'a, N: NetworkListener + 'a> Iterator for NetworkConnections<'a, N> { | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
| /// An abstraction over streams that a Server can utilize. | ||||
| pub trait NetworkStream: Read + Write + Any + StreamClone + Send + Typeable { | ||||
| pub trait NetworkStream: Read + Write + Any + Send + Typeable { | ||||
|     /// Get the remote address of the underlying connection. | ||||
|     fn peer_addr(&mut self) -> io::Result<SocketAddr>; | ||||
| } | ||||
|  | ||||
| #[doc(hidden)] | ||||
| pub trait StreamClone { | ||||
|     fn clone_box(&self) -> Box<NetworkStream + Send>; | ||||
| } | ||||
|  | ||||
| impl<T: NetworkStream + Send + Clone> StreamClone for T { | ||||
|     #[inline] | ||||
|     fn clone_box(&self) -> Box<NetworkStream + Send> { | ||||
|         Box::new(self.clone()) | ||||
|     } | ||||
| } | ||||
|  | ||||
| /// A connector creates a NetworkStream. | ||||
| pub trait NetworkConnector { | ||||
|     /// Type of Stream to create | ||||
| @@ -92,11 +79,6 @@ impl fmt::Debug for Box<NetworkStream + Send> { | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl Clone for Box<NetworkStream + Send> { | ||||
|     #[inline] | ||||
|     fn clone(&self) -> Box<NetworkStream + Send> { self.clone_box() } | ||||
| } | ||||
|  | ||||
| impl NetworkStream + Send { | ||||
|     unsafe fn downcast_ref_unchecked<T: 'static>(&self) -> &T { | ||||
|         mem::transmute(traitobject::data(self)) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user