pub fn from_source(source: &str) -> Result<Self, TskError> {
        // Create a CString for the provided source
        let source = CString::new(source)
            .map_err(|e| TskError::generic(format!("Unable to create CString from source: {:?}", e)))?;

        // Get a pointer to the TSK_IMG_INFO sturct
        let tsk_img = unsafe {tsk::tsk_img_open_utf8_sing(
            source.as_ptr() as _,
            tsk::TSK_IMG_TYPE_ENUM_TSK_IMG_TYPE_RAW_SING,
            0
        )};
        
        // Ensure that the ptr is not null
        let handle = match NonNull::new(tsk_img) {
            None => {
                // Get a ptr to the error msg
                let error_msg_ptr = unsafe { tsk::tsk_error_get() };
                // Get the error message from the string
                let error_msg = unsafe { CStr::from_ptr(error_msg_ptr) }.to_string_lossy();
                // Return an error which includes the TSK error message
                return Err(TskError::lib_tsk_error(
                    format!("There was an error opening the img handle: {}", error_msg)
                ));
            },
            Some(h) => h
        };

        Ok( Self { handle } )
    }
/// Create a TskImg wrapper from a given source.
/// 
Create a TskImg wrapper from a given source.
Create a TskImg wrapper from a given source .
pub fn from_source(source: &str) -> Result<Self, TskError> {
        // Create a CString for the provided source
        let source = CString::new(source)
            .map_err(|e| TskError::generic(format!("Unable to create CString from source: {:?}", e)))?;
        // Get a pointer to the TSK_IMG_INFO sturct
        let tsk_img = unsafe {tsk::tsk_img_open_utf8_sing(
            source.as_ptr() as _,
            tsk::TSK_IMG_TYPE_ENUM_TSK_IMG_TYPE_RAW_SING,
            0
        )};
        // Ensure that the ptr is not null
        let handle = match NonNull::new(tsk_img) {
            None => {
                // Get a ptr to the error msg
                let error_msg_ptr = unsafe { tsk::tsk_error_get() };
                // Get the error message from the string
                let error_msg = unsafe { CStr::from_ptr(error_msg_ptr) }.to_string_lossy();
                // Return an error which includes the TSK error message
                return Err(TskError::lib_tsk_error(
                    format!("There was an error opening the img handle: {}", error_msg)
                ));
            },
            Some(h) => h
        };
        Ok( Self { handle } )
    }
pub fn from_source ( source : & str ) -> Result < Self , TskError > { // Create a CString for the provided source let source = CString :: new ( source ) . map_err ( | e | TskError :: generic ( format ! ( " " e ) ) ) ? ; // Get a pointer to the TSK_IMG_INFO sturct let tsk_img = unsafe { tsk :: tsk_img_open_utf8_sing ( source . as_ptr ( ) as _ , tsk :: TSK_IMG_TYPE_ENUM_TSK_IMG_TYPE_RAW_SING , 0 ) } ; // Ensure that the ptr is not null let handle = match NonNull :: new ( tsk_img ) { None => { // Get a ptr to the error msg let error_msg_ptr = unsafe { tsk :: tsk_error_get ( ) } ; // Get the error message from the string let error_msg = unsafe { CStr :: from_ptr ( error_msg_ptr ) } . to_string_lossy ( ) ; // Return an error which includes the TSK error message return Err ( TskError :: lib_tsk_error ( format ! ( " " error_msg ) ) ) ; } , Some ( h ) => h } ; Ok ( Self { handle } ) }
Create a TskImg wrapper from a given source.
Create a TskImg wrapper from a given source .
source
&str