pub fn new(mut stream: &mut TcpStream) -> Result<Packet, &'static str> {
        let mut data = match stream
                .bytes()
                .map(|i| i.unwrap())
                .get_varint() as usize
                {
            len @ 1...1024 => vec![0; len],
            _ => return Err("Packet Forming error: Packet wrong \
                             size or stream Terminated"),
        }; 
                
        let pack =  { 
            let mut temp = match stream.read_exact(&mut data) {
                Ok(_) => Packet {
                    id: 255,
                    data: data.into_iter()
                },
                Err(_) => return Err("Error reading Packet"),
            };
            temp.id = temp.get_varint() as u8;
            temp
        };
        
        Ok(pack)
    }
// Takes a tcp stream and pulls a packet from it
// MAJOR FIX : no guarantee of full packet
Takes a tcp stream and pulls a packet from it
MAJOR FIX : no guarantee of full packet
Takes a tcp stream and pulls a packet from it MAJOR FIX : no guarantee of full packet
pub fn new(mut stream: &mut TcpStream) -> Result<Packet, &'static str> {
        let mut data = match stream
                .bytes()
                .map(|i| i.unwrap())
                .get_varint() as usize
                {
            len @ 1...1024 => vec![0; len],
            _ => return Err("Packet Forming error: Packet wrong \
                             size or stream Terminated"),
        }; 
        let pack =  { 
            let mut temp = match stream.read_exact(&mut data) {
                Ok(_) => Packet {
                    id: 255,
                    data: data.into_iter()
                },
                Err(_) => return Err("Error reading Packet"),
            };
            temp.id = temp.get_varint() as u8;
            temp
        };
        Ok(pack)
    }
pub fn new ( mut stream : & mut TcpStream ) -> Result < Packet , & ' static str > { let mut data = match stream . bytes ( ) . map ( | i | i . unwrap ( ) ) . get_varint ( ) as usize { len @ 1 ... 1024 => vec ! [ 0 len ] , _ => return Err ( " \
 " ) , } ; let pack = { let mut temp = match stream . read_exact ( & mut data ) { Ok ( _ ) => Packet { id : 255 , data : data . into_iter ( ) } , Err ( _ ) => return Err ( " " ) , } ; temp . id = temp . get_varint ( ) as u8 ; temp } ; Ok ( pack ) }
Takes a tcp stream and pulls a packet from it
MAJOR FIX : no guarantee of full packet
Takes a tcp stream and pulls a packet from it MAJOR FIX : no guarantee of full packet
stream
&mut TcpStream
stream
&mut TcpStream