[−][src]Macro glsp::lib
Defines a library struct.
The input must be a struct declaration. The macro defines that struct, implements the
Lib
trait for the struct's type, and implements MakeArg
for shared and mutable references to the struct's type.
lib! { struct Graphics { canvas: sdl2::render::Canvas<Window> } } impl Graphics { fn draw_rect(&self, rect: Rect) { self.canvas.draw_rect(rect).unwrap(); } } glsp::bind_rfn("draw-rect", rfn!(Graphics::draw_rect))?;
When a reference to a library struct is bound as an RFn
parameter, that parameter doesn't
consume any input arguments. Instead, it will attempt to borrow
the library struct from the active Runtime
.