Skip to content

Commit

Permalink
feat(client): remove Clone requirement for NetworkStream in Client
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Apr 23, 2015
1 parent e814680 commit 60d92c2
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down

0 comments on commit 60d92c2

Please sign in to comment.