/// Specify path to load the librute from. Notice that this shouldn't include the
/// actually file name but only the path to the filename. This make it easier for the user
/// as filename may be different depending on platform
Specify path to load the librute from. Notice that this shouldn't include the
actually file name but only the path to the filename. This make it easier for the user
as filename may be different depending on platform
Specify path to load the librute from . Notice that this shouldn ' t include the actually file name but only the path to the filename . This make it easier for the user as filename may be different depending on platform
pub fn new_from_path(path: &str) -> Result<Rute, String> {
        let data = match fs::metadata(path) {
            Err(e) => {
                return Err(format!("Unable to find file {}: error {}", path, e));
            }
            Ok(data) => data,
        };
        // Make sure we are trying ot open a file
        if !data.is_file() {
            return Err(format!("Rute: Path is not a file: {}", path));
        }
        // Load the library
        let lib = match Library::new(path) {
            Err(e) => return Err(format!("Found Rute sharedlib at {} but was unable to open it.
                                         This can be because of the Qt sharedlibs/dlls not being in path.
                                         Make sure they are and try again: error {}", path, e)),
            Ok(lib) => Rc::new(lib),
        };
        // Find the entry symbol in the library
        let rute_get;
        unsafe {
            let t: Result<Symbol<unsafe extern "C" fn() -> *const ffi::RuteFFI>, ::std::io::Error> = lib.get(b"rute_get\0");
            rute_get = match t {
                Ok(func) => func,
                Err(e) => {
                    return Err(format!("Loaded Rute sharedlib {} but was unable to find \"rute_get\" function in the lib: error {}", path, e));
                }
            };
        }
        Ok(Rute {
            _lib: lib.clone(),
            ffi_api: unsafe { rute_get() },
        })
    }
pub fn new_from_path ( path : & str ) -> Result < Rute , String > { let data = match fs :: metadata ( path ) { Err ( e ) => { return Err ( format ! ( " " path e ) ) ; } Ok ( data ) => data , } ; // Make sure we are trying ot open a file if ! data . is_file ( ) { return Err ( format ! ( " " path ) ) ; } // Load the library let lib = match Library :: new ( path ) { Err ( e ) => return Err ( format ! ( " " path e ) ) , Ok ( lib ) => Rc :: new ( lib ) , } ; // Find the entry symbol in the library let rute_get ; unsafe { let t : Result < Symbol < unsafe extern " " fn ( ) -> * const ffi :: RuteFFI > , :: std :: io :: Error > = lib . get ( b" \0 " ) ; rute_get = match t { Ok ( func ) => func , Err ( e ) => { return Err ( format ! ( " \" \" " path e ) ) ; } } ; } Ok ( Rute { _lib : lib . clone ( ) , ffi_api : unsafe { rute_get ( ) } , } ) }
Specify path to load the librute from.
Specify path to load the librute from .
path
&str