rust - libloading and async dynamic lib function - Stack Overflow

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

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744847369a4596921.html

相关推荐

  • rust - libloading and async dynamic lib function - Stack Overflow

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

    2天前
    90

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信