/// Create a new CaptureBuilder for a given device.
Create a new CaptureBuilder for a given device.
Create a new CaptureBuilder for a given device .
pub fn new(pc: ThreadingContext, dname: &str) -> Result<CaptureBuilder> {
        let mut result = CaptureBuilder {
            capture: Capture {
                pc:     pc,
                errbuf: Box::new([0; 4096]),
                h:      ptr::null_mut()
            }
        };
        let dname_cstr = CString::new(dname).unwrap();
        let dname_ptr = dname_cstr.as_ptr() as *const c_char;
        let errbuf_ptr = result.capture.errbuf.as_mut_ptr();
        result.capture.h = unsafe {
            pcap_create(dname_ptr, errbuf_ptr as *mut c_char)
        };
        if result.capture.h.is_null() {
            Err(unsafe { PcapError::from_cstr(errbuf_ptr as *const c_char) })
        } else {
            Ok(result)
        }
    }
pub fn new ( pc : ThreadingContext , dname : & str ) -> Result < CaptureBuilder > { let mut result = CaptureBuilder { capture : Capture { pc : pc , errbuf : Box :: new ( [ 0 ; 4096 ] ) , h : ptr :: null_mut ( ) } } ; let dname_cstr = CString :: new ( dname ) . unwrap ( ) ; let dname_ptr = dname_cstr . as_ptr ( ) as * const c_char ; let errbuf_ptr = result . capture . errbuf . as_mut_ptr ( ) ; result . capture . h = unsafe { pcap_create ( dname_ptr , errbuf_ptr as * mut c_char ) } ; if result . capture . h . is_null ( ) { Err ( unsafe { PcapError :: from_cstr ( errbuf_ptr as * const c_char ) } ) } else { Ok ( result ) } }
Create a new CaptureBuilder for a given device.
Create a new CaptureBuilder for a given device .
pc
ThreadingContext
dname
&str