use crate::{Functions, FunctionsFn}; use libloading::Library; use std::sync::Arc; #[derive(Clone)] pub struct Lib { pub lib: Arc, pub functions: Functions, } impl Lib { pub unsafe fn new(lib: Library) -> Result { let load_fn: libloading::Symbol = lib.get(b"functions")?; let functions = load_fn(); if functions.size != std::mem::size_of::() { return Err(anyhow::Error::msg( "Lib Functions size != app Functions size", )); } Ok(Self { lib: Arc::new(lib), functions, }) } }