use std::string;



pub struct HandShake<'a> {
    len_pack: u8,
    len_dom: u8,
    datagram: &'a[u8],
    host: &'a[u8],
    port: &'a[u8],
}

impl<'a> HandShake<'a>{
    pub fn new(data: &[u8]) -> HandShake {
        let len_pack = data[0];
        println!("{}", len_pack);
        let len_dom = data[4];
        println!("{}", len_dom);
        HandShake {
            len_pack: len_pack,
            len_dom: len_dom,
            datagram: data.clone(),
            host: (&data[5 .. ((len_dom + 5) as usize)]).clone(),
            port: (&data[((len_pack - 2) as usize) .. ((len_pack - 1) as usize)]).clone(),
        }
    }

    pub fn getHostName(&self) -> String {
        String::from_utf8(self.datagram[5 .. ((self.len_dom+5) as usize)].to_vec()).unwrap()
    }
}
