diff --git a/ash/Cargo.toml b/ash/Cargo.toml index 2d2fec2..775e25c 100644 --- a/ash/Cargo.toml +++ b/ash/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/ash" edition = "2018" [dependencies] -shared_library = "0.1.9" +libloading = "0.5.2" [features] default = [] diff --git a/ash/src/entry.rs b/ash/src/entry.rs index a181818..f7d119a 100644 --- a/ash/src/entry.rs +++ b/ash/src/entry.rs @@ -2,13 +2,13 @@ use crate::instance::Instance; use crate::prelude::*; use crate::vk; use crate::RawPtr; -use shared_library::dynamic_library::DynamicLibrary; +use libloading::Library; use std::error::Error; use std::fmt; +use std::io; use std::mem; use std::os::raw::c_char; use std::os::raw::c_void; -use std::path::Path; use std::ptr; use std::sync::Arc; @@ -28,7 +28,7 @@ const LIB_PATH: &str = "libvulkan.so"; const LIB_PATH: &str = "libvulkan.dylib"; /// Function loader -pub type Entry = EntryCustom>; +pub type Entry = EntryCustom>; /// Function loader #[derive(Clone)] @@ -40,9 +40,9 @@ pub struct EntryCustom { lib: L, } -#[derive(Clone, Debug)] +#[derive(Debug)] pub enum LoadingError { - LibraryLoadError(String), + LibraryLoadError(io::Error), } impl fmt::Display for LoadingError { @@ -206,7 +206,7 @@ impl EntryV1_2 for EntryCustom { } } -impl EntryCustom> { +impl EntryCustom> { /// ```rust,no_run /// use ash::{vk, Entry, version::EntryV1_0}; /// # fn main() -> Result<(), Box> { @@ -225,13 +225,14 @@ impl EntryCustom> { pub fn new() -> Result { Self::new_custom( || { - DynamicLibrary::open(Some(&Path::new(LIB_PATH))) + Library::new(&LIB_PATH) .map_err(LoadingError::LibraryLoadError) .map(Arc::new) }, |vk_lib, name| unsafe { vk_lib - .symbol(&*name.to_string_lossy()) + .get(name.to_bytes_with_nul()) + .map(|symbol| *symbol) .unwrap_or(ptr::null_mut()) }, )