pub fn query(&mut self,
                 dname: &[u8],
                 class: Class,
                 typ: RecordType)
                 -> Result<Response, Error>
    {
        let name = match CString::new(dname) {
            Ok(c) => c,
            Err(n) => return Err(Error::CString(n)),
        };
        let buflen: usize = libresolv_sys::NS_PACKETSZ as usize;
        let mut buffer: Box<Vec<u8>> = Box::new(Vec::with_capacity(buflen));

        let rlen: i32 = unsafe {
            libresolv_sys::__res_nquery(
                &mut self.context,
                name.as_ptr(),
                class as i32,
                typ as i32,
                buffer.deref_mut().as_mut_ptr(),
                buflen as i32)
        };
        if rlen==-1 {
            return Err(From::from(self.get_error()));
        }

        let mut msg: libresolv_sys::__ns_msg = libresolv_sys::__ns_msg::default();
        unsafe {
            if libresolv_sys::ns_initparse(buffer.deref().as_ptr(), rlen, &mut msg) < 0 {
                return Err(Error::ParseError);
            }
        }

        Ok(Response::new(msg, buffer))
    }
/// Lookup the record.  Does not apply the search algorithm, so `dname` must be a complete
/// domain name, and only DNS will be consulted (not your hosts file).  Applies recursion
/// if available and not turned off (it is on by default).
Lookup the record.  Does not apply the search algorithm, so `dname` must be a complete
domain name, and only DNS will be consulted (not your hosts file).  Applies recursion
if available and not turned off (it is on by default).
Lookup the record . Does not apply the search algorithm so ` dname ` must be a complete domain name and only DNS will be consulted ( not your hosts file ) . Applies recursion if available and not turned off ( it is on by default ) .
pub fn query(&mut self,
                 dname: &[u8],
                 class: Class,
                 typ: RecordType)
                 -> Result<Response, Error>
    {
        let name = match CString::new(dname) {
            Ok(c) => c,
            Err(n) => return Err(Error::CString(n)),
        };
        let buflen: usize = libresolv_sys::NS_PACKETSZ as usize;
        let mut buffer: Box<Vec<u8>> = Box::new(Vec::with_capacity(buflen));
        let rlen: i32 = unsafe {
            libresolv_sys::__res_nquery(
                &mut self.context,
                name.as_ptr(),
                class as i32,
                typ as i32,
                buffer.deref_mut().as_mut_ptr(),
                buflen as i32)
        };
        if rlen==-1 {
            return Err(From::from(self.get_error()));
        }
        let mut msg: libresolv_sys::__ns_msg = libresolv_sys::__ns_msg::default();
        unsafe {
            if libresolv_sys::ns_initparse(buffer.deref().as_ptr(), rlen, &mut msg) < 0 {
                return Err(Error::ParseError);
            }
        }
        Ok(Response::new(msg, buffer))
    }
pub fn query ( & mut self , dname : & [ u8 ] , class : Class , typ : RecordType ) -> Result < Response , Error > { let name = match CString :: new ( dname ) { Ok ( c ) => c , Err ( n ) => return Err ( Error :: CString ( n ) ) , } ; let buflen : usize = libresolv_sys :: NS_PACKETSZ as usize ; let mut buffer : Box < Vec < u8 > > = Box :: new ( Vec :: with_capacity ( buflen ) ) ; let rlen : i32 = unsafe { libresolv_sys :: __res_nquery ( & mut self . context , name . as_ptr ( ) , class as i32 , typ as i32 , buffer . deref_mut ( ) . as_mut_ptr ( ) , buflen as i32 ) } ; if rlen == - 1 { return Err ( From :: from ( self . get_error ( ) ) ) ; } let mut msg : libresolv_sys :: __ns_msg = libresolv_sys :: __ns_msg :: default ( ) ; unsafe { if libresolv_sys :: ns_initparse ( buffer . deref ( ) . as_ptr ( ) , rlen , & mut msg ) < 0 { return Err ( Error :: ParseError ) ; } } Ok ( Response :: new ( msg , buffer ) ) }
Lookup the record.
Lookup the record .
&mut self
dname
&[u8]
class
Class
typ
RecordType
&mut self
dname
&[u8]
class
Class
typ
RecordType