pub struct Bridge { /* private fields */ }Expand description
One world plus the text of its last answer, owned by the host through a pointer.
Implementations§
Source§impl Bridge
impl Bridge
Sourcepub fn new(
width: f64,
height: f64,
scroll_width: f64,
scroll_height: f64,
) -> Option<Bridge>
pub fn new( width: f64, height: f64, scroll_width: f64, scroll_height: f64, ) -> Option<Bridge>
A world for a root scroll area of the given window and content size, None on
non-finite sizes.
Sourcepub fn run(&mut self, line: &str) -> usize
pub fn run(&mut self, line: &str) -> usize
Runs one JSON command line and keeps the answer; returns its length in bytes.
Sourcepub fn read(&mut self) -> usize
pub fn read(&mut self) -> usize
Keeps the JSON state snapshot as answer and drains the events; returns its length.
Sourcepub fn frame(&mut self, time: f64) -> bool
pub fn frame(&mut self, time: f64) -> bool
Advances to the host time in milliseconds; answers whether another frame is needed.
Source#[unsafe(no_mangle)]pub extern "C" fn ruanim_new(
width: f64,
height: f64,
scroll_width: f64,
scroll_height: f64,
) -> *mut Bridge
#[unsafe(no_mangle)]pub extern "C" fn ruanim_new(
width: f64,
height: f64,
scroll_width: f64,
scroll_height: f64,
) -> *mut Bridge
Creates a bridge; null on non-finite sizes. Free it with ruanim_free.
Source#[unsafe(no_mangle)]pub unsafe extern "C" fn ruanim_free(bridge: *mut Bridge)
#[unsafe(no_mangle)]pub unsafe extern "C" fn ruanim_free(bridge: *mut Bridge)
Source#[unsafe(no_mangle)]pub extern "C" fn ruanim_buffer(len: usize) -> *mut u8
#[unsafe(no_mangle)]pub extern "C" fn ruanim_buffer(len: usize) -> *mut u8
Reserves len zeroed bytes for the host to write a command line into.
Source#[unsafe(no_mangle)]pub unsafe extern "C" fn ruanim_release(buffer: *mut u8, len: usize)
#[unsafe(no_mangle)]pub unsafe extern "C" fn ruanim_release(buffer: *mut u8, len: usize)
Releases bytes from ruanim_buffer.
§Safety
buffer is null or came from ruanim_buffer(len) with the same len and is not used
again.
Source#[unsafe(no_mangle)]pub unsafe extern "C" fn ruanim_run(
bridge: *mut Bridge,
line: *const u8,
len: usize,
) -> usize
#[unsafe(no_mangle)]pub unsafe extern "C" fn ruanim_run(
bridge: *mut Bridge,
line: *const u8,
len: usize,
) -> usize
Runs the command line in line[..len]; returns the answer length, 0 for a null bridge.
Bytes that are not UTF-8 are answered as malformed JSON.
§Safety
bridge is null or live from ruanim_new; line is null or valid for len bytes.
Source#[unsafe(no_mangle)]pub unsafe extern "C" fn ruanim_read(bridge: *mut Bridge) -> usize
#[unsafe(no_mangle)]pub unsafe extern "C" fn ruanim_read(bridge: *mut Bridge) -> usize
Stores the state snapshot as answer; returns its length, 0 for a null bridge.
§Safety
bridge is null or live from ruanim_new.
Source#[unsafe(no_mangle)]pub unsafe extern "C" fn ruanim_frame(
bridge: *mut Bridge,
time: f64,
) -> u32
#[unsafe(no_mangle)]pub unsafe extern "C" fn ruanim_frame(
bridge: *mut Bridge,
time: f64,
) -> u32
Advances to time; returns 1 while frames are needed, 0 at rest or for a null bridge.
§Safety
bridge is null or live from ruanim_new.
Source#[unsafe(no_mangle)]pub unsafe extern "C" fn ruanim_output(
bridge: *const Bridge,
) -> *const u8
#[unsafe(no_mangle)]pub unsafe extern "C" fn ruanim_output(
bridge: *const Bridge,
) -> *const u8
Start of the last answer, valid until the next call on this bridge.
§Safety
bridge is null or live from ruanim_new.
Source#[unsafe(no_mangle)]pub unsafe extern "C" fn ruanim_values(
bridge: *const Bridge,
) -> *const f64
#[unsafe(no_mangle)]pub unsafe extern "C" fn ruanim_values(
bridge: *const Bridge,
) -> *const f64
Start of the lane values, valid until the next call on this bridge.
§Safety
bridge is null or live from ruanim_new.