mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-09-15 17:26:58 +00:00
Hot-Reloading Refactor
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
ae1a4fd283
commit
6c1434c165
212 changed files with 5679 additions and 4206 deletions
23
src/core/mods/new.rs
Normal file
23
src/core/mods/new.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
use std::ffi::OsStr;
|
||||
|
||||
use super::{path, Library};
|
||||
use crate::{Error, Result};
|
||||
|
||||
const OPEN_FLAGS: i32 = libloading::os::unix::RTLD_LAZY | libloading::os::unix::RTLD_GLOBAL;
|
||||
|
||||
pub fn from_name(name: &str) -> Result<Library> {
|
||||
let path = path::from_name(name)?;
|
||||
from_path(&path)
|
||||
}
|
||||
|
||||
pub fn from_path(path: &OsStr) -> Result<Library> {
|
||||
//SAFETY: Calls dlopen(3) on unix platforms. This might not have to be unsafe
|
||||
// if wrapped in with_dlerror.
|
||||
let lib = unsafe { Library::open(Some(path), OPEN_FLAGS) };
|
||||
if let Err(e) = lib {
|
||||
let name = path::to_name(path)?;
|
||||
return Err(Error::Err(format!("Loading module {name:?} failed: {e}")));
|
||||
}
|
||||
|
||||
Ok(lib.expect("module loaded"))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue