pub trait LuaHost {
Show 15 methods
// Required method
fn run(
&self,
engine: &mut Engine,
name: &str,
code: &[u8],
) -> Result<(), String>;
// Provided methods
fn dump(&self, _engine: &mut Engine) -> Vec<u8> ⓘ { ... }
fn undump(&self, _engine: &mut Engine, _data: &[u8]) -> Result<(), String> { ... }
fn call_simple(
&self,
_engine: &mut Engine,
_name: &str,
) -> Result<(), String> { ... }
fn call_with_string(
&self,
_engine: &mut Engine,
_name: &str,
_arg: &str,
) -> Result<(), String> { ... }
fn has_callback(&self, _name: &str) -> bool { ... }
fn define_font(
&self,
_engine: &mut Engine,
_name: &[u8],
_size: i32,
) -> Option<u32> { ... }
fn list_filter(
&self,
_engine: &mut Engine,
_callback: &str,
head: NodeRef,
_group: &str,
) -> ListFilter { ... }
fn pack_quality(
&self,
_engine: &mut Engine,
_cb: &str,
_incident: &str,
_detail: i32,
_b: NodeRef,
_first: i32,
_last: i32,
) -> NodeRef { ... }
fn node_pass(&self, _engine: &mut Engine, _cb: &str, _head: NodeRef) -> bool { ... }
fn linebreak_filter(
&self,
_engine: &mut Engine,
_head: NodeRef,
_display: bool,
) -> Option<NodeRef> { ... }
fn mlist_to_hlist(
&self,
_engine: &mut Engine,
_head: NodeRef,
_style: i32,
_penalties: bool,
) -> Option<NodeRef> { ... }
fn pipe_read(&self, _engine: &mut Engine, _cmd: &[u8]) -> Option<Vec<u8>> { ... }
fn input_level_string(
&self,
_engine: &mut Engine,
_n: i64,
) -> Option<Vec<u8>> { ... }
fn glyph_info(&self, _engine: &mut Engine, _p: NodeRef) -> Option<Vec<u8>> { ... }
}Expand description
Callbacks from the engine into an embedded Lua interpreter.
The engine does not depend on Lua. \directlua and related primitives
call this trait, which retex-lua implements. The host is shared
(Rc), so nested calls (Lua → TeX → Lua) reach it too.
Required Methods§
Provided Methods§
Sourcefn dump(&self, _engine: &mut Engine) -> Vec<u8> ⓘ
fn dump(&self, _engine: &mut Engine) -> Vec<u8> ⓘ
Data to store in the format file (e.g. lua.bytecode).
Sourcefn undump(&self, _engine: &mut Engine, _data: &[u8]) -> Result<(), String>
fn undump(&self, _engine: &mut Engine, _data: &[u8]) -> Result<(), String>
Restores data stored by dump.
Sourcefn call_simple(&self, _engine: &mut Engine, _name: &str) -> Result<(), String>
fn call_simple(&self, _engine: &mut Engine, _name: &str) -> Result<(), String>
Calls callback name without arguments, ignoring its results
(pre_dump, stop_run, …). Does nothing if none is registered.
Sourcefn call_with_string(
&self,
_engine: &mut Engine,
_name: &str,
_arg: &str,
) -> Result<(), String>
fn call_with_string( &self, _engine: &mut Engine, _name: &str, _arg: &str, ) -> Result<(), String>
Calls callback name with one string argument, ignoring its
results (buildpage_filter, contribute_filter).
Sourcefn has_callback(&self, _name: &str) -> bool
fn has_callback(&self, _name: &str) -> bool
Whether a Lua function is registered for callback name.
Sourcefn define_font(
&self,
_engine: &mut Engine,
_name: &[u8],
_size: i32,
) -> Option<u32>
fn define_font( &self, _engine: &mut Engine, _name: &[u8], _size: i32, ) -> Option<u32>
Calls the define_font callback. Returns the id of the font it
defined, or None if the font could not be loaded.
Sourcefn list_filter(
&self,
_engine: &mut Engine,
_callback: &str,
head: NodeRef,
_group: &str,
) -> ListFilter
fn list_filter( &self, _engine: &mut Engine, _callback: &str, head: NodeRef, _group: &str, ) -> ListFilter
Calls a node-list filter callback (pre_linebreak_filter,
hpack_filter, post_linebreak_filter, …) on the list starting at
head. Returns the new head; ListFilter::Flush means the list
must be discarded.
Sourcefn pack_quality(
&self,
_engine: &mut Engine,
_cb: &str,
_incident: &str,
_detail: i32,
_b: NodeRef,
_first: i32,
_last: i32,
) -> NodeRef
fn pack_quality( &self, _engine: &mut Engine, _cb: &str, _incident: &str, _detail: i32, _b: NodeRef, _first: i32, _last: i32, ) -> NodeRef
Calls the hpack_quality or vpack_quality callback cb for box
b with incident (overfull, underfull, loose, tight) and its
detail; returns the node the callback gave (null if none).
Sourcefn node_pass(&self, _engine: &mut Engine, _cb: &str, _head: NodeRef) -> bool
fn node_pass(&self, _engine: &mut Engine, _cb: &str, _head: NodeRef) -> bool
Runs the hyphenate, ligaturing or kerning callback cb on
the list after head (a temporary node), with its last node:
true if a function or false is registered, which replaces the
built-in pass.
Sourcefn linebreak_filter(
&self,
_engine: &mut Engine,
_head: NodeRef,
_display: bool,
) -> Option<NodeRef>
fn linebreak_filter( &self, _engine: &mut Engine, _head: NodeRef, _display: bool, ) -> Option<NodeRef>
Calls the linebreak_filter callback on paragraph head
(display: a display follows): Some(list) if it returned a node
list, which replaces line breaking; None otherwise.
Sourcefn mlist_to_hlist(
&self,
_engine: &mut Engine,
_head: NodeRef,
_style: i32,
_penalties: bool,
) -> Option<NodeRef>
fn mlist_to_hlist( &self, _engine: &mut Engine, _head: NodeRef, _style: i32, _penalties: bool, ) -> Option<NodeRef>
Calls the mlist_to_hlist callback on math list head in style
style (0–7); None if the callback failed or none is set.
Sourcefn pipe_read(&self, _engine: &mut Engine, _cmd: &[u8]) -> Option<Vec<u8>>
fn pipe_read(&self, _engine: &mut Engine, _cmd: &[u8]) -> Option<Vec<u8>>
Runs shell command cmd under the shell escape rules (as Lua’s
io.popen does) and returns its output; None if it may not run.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".