plat/modhost.rs#
Source: lib/plat/modhost.rs
modhost -- loadable modules, the host side (jxl-module): the JPEG XL writer module jxlenc
[jxl-module: no asm]
jxlenc_set_path(Some(path) | None) the module file: None = <exe folder>/jxlenc.dll
(Linux jxlenc.so); "off" = none. Before the first use.
jxlenc_ready() -> bool the module is loaded (loads it on the first call and keeps it;
a missing / refused file stays missing for the process)
jxlenc_file() -> path the file the module was (or would be) loaded from
jxlenc_encode(req) -> Some(file / ERR_*) | None (no module)
module_at(addr) -> Some((file name, image base)) the loaded module holding addr (crash
reports: offsets into its .map; allocation-free)
The module (modules/jxlenc) is a no_std cdylib without imports, loaded with the plugin
loader (lib_open / lib_sym: win_lib.rs, linux_elfload.rs -- the same checks), its one export
jxlenc_module(&HostTable) -> &ModTable (modabi.rs: the records, the memory and thread rules).
It is our own code, called without a guard: a fault inside it is a crash with the normal
report, a panic comes back through HostTable::panic into rt::crash::report. The JPEG XL
specifics (what JxlReq carries) are img_jxl::writer's; this file only moves the bytes.
jfgui_JXLENC_TEST=panic | fault (tests) makes the module panic / fault in its encode.
/// the module's file name next to the exe
JXLENC_FILE: &str = "jxlenc.dll"
/// the module's file name next to the exe
JXLENC_FILE: &str = "jxlenc.so"
fn module_at(addr: u64) -> Option<(&'static str, u64)>the loaded module holding addr: (its file name, its image base) -- for crash reports (no lock, no allocation)fn jxlenc_set_path(path: Option<String>)the module file to load (None = the default next to the exe, "off" = none); resets an earlier failed attempt, never a loaded modulefn current_exe() -> Option<String>Absolute path of the running native executable, independent of argv[0].fn jxlenc_file() -> Option<String>the file the module is (or would be) loaded from; None = "off" / no exe folderfn jxlenc_ready() -> boolthe module is loaded (the first call loads it)struct JxlEncReq<'a>a JPEG XL encode for the module (img_jxl::writer): the samples (owned: they move to the module) and the writer's optionsw: u32h: u32gray: boolalpha: boolrgba: Vec<u8>effort: u32quality: u32flags: u32icc: Option<&'a [u8]>exif: Option<&'a [u8]>xmp: Option<&'a [u8]>cancel: Option<&'a AtomicU32>
fn jxlenc_encode(req: JxlEncReq) -> Option<Result<Vec<u8>, i32>>the module's writer on req: Some(file / ERR_*), None without a module