最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

rust - libloading and async dynamic lib function - Stack Overflow

programmeradmin2浏览0评论

I created a dynamic lib from rust. I woul like to import it into another app. Sp I use libloading

I do

fn call_dynamic() -> Result<u32, Box<dyn std::error::Error>> {
    unsafe {
        let lib = libloading::Library::new("/path/to/liblibrary.so")?;
        let func: libloading::Symbol<unsafe extern fn()> = lib.get(b"my_func")?;
        Ok(func())
    }
}

But the dynamic lib is async (it use tokio). My another app use tokio:

#[tokio::main]
async fn main() {
// load dyn lib
}

my_func:

#[no_mangle]
pub async fn my_func()  {
//do async stuff 
// I use external crate which depends on tokio anc his runtime
}

But I cannot see the log from the lib.

I think I have to do an await on loading the lib.

But how to do this ?

Thanks

发布评论

评论列表(0)

  1. 暂无评论