Rename trait and clean
This commit is contained in:
		
							parent
							
								
									84b39aa2a7
								
							
						
					
					
						commit
						930a1a3692
					
				| @ -3,14 +3,13 @@ use std::net::TcpStream; | ||||
| use std::os::unix::net::UnixListener; | ||||
| use std::os::unix::net::UnixStream; | ||||
| use std::io::{Error, ErrorKind}; | ||||
| use std::io::prelude::*; | ||||
| 
 | ||||
| pub const TCP_LIS : u8 = 0; | ||||
| pub const UNIX_LIS : u8 = 1; | ||||
| 
 | ||||
| pub trait NewTrait: std::io::Read + std::io::Write + Send {} | ||||
| impl NewTrait for TcpStream {} | ||||
| impl NewTrait for UnixStream {} | ||||
| pub trait RWTrait: std::io::Read + std::io::Write + Send {} | ||||
| impl RWTrait for TcpStream {} | ||||
| impl RWTrait for UnixStream {} | ||||
| 
 | ||||
| pub struct GenericListener { | ||||
|     tcp_lis : Option<TcpListener>, | ||||
| @ -46,7 +45,7 @@ impl GenericListener { | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     pub fn accept(&self) -> Result<Box<dyn NewTrait>,Error> { | ||||
|     pub fn accept(&self) -> Result<Box<dyn RWTrait>,Error> { | ||||
|         match self.type_lis { | ||||
|             TCP_LIS => Ok(Box::new(self.tcp_lis.as_ref().unwrap().accept()?.0)), | ||||
|             UNIX_LIS => Ok(Box::new(self.unix_lis.as_ref().unwrap().accept()?.0)), | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user