Skip to main content

Bridge

Struct Bridge 

Source
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

Source

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.

Source

pub fn run(&mut self, line: &str) -> usize

Runs one JSON command line and keeps the answer; returns its length in bytes.

Source

pub fn read(&mut self) -> usize

Keeps the JSON state snapshot as answer and drains the events; returns its length.

Source

pub fn frame(&mut self, time: f64) -> bool

Advances to the host time in milliseconds; answers whether another frame is needed.

Source

pub fn output(&self) -> &str

The last answer.

Source

pub fn values(&self) -> &[f64]

All lane values.

Source

pub fn scroll(&self) -> f64

The root scroll position.

Source

#[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)

Frees a bridge.

§Safety

bridge is null or came from ruanim_new and is not used again.

Source

#[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)

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

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

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

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

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

Start of the lane values, 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_len( bridge: *const Bridge, ) -> usize

Number of lane values.

§Safety

bridge is null or live from ruanim_new.

Source

#[unsafe(no_mangle)]
pub unsafe extern "C" fn ruanim_scroll(bridge: *const Bridge) -> f64

The root scroll position, NaN for a null bridge.

§Safety

bridge is null or live from ruanim_new.

Trait Implementations§

Source§

impl Debug for Bridge

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Bridge

§

impl Freeze for Bridge

§

impl Move for Bridge

§

impl RefUnwindSafe for Bridge

§

impl Send for Bridge
where RawVecInner: Send, &'static str: Send,

§

impl Sync for Bridge
where RawVecInner: Sync,

§

impl Unpin for Bridge
where *const u8 is !null: Unpin, &'static str: Unpin,

§

impl UnsafeUnpin for Bridge

§

impl UnwindSafe for Bridge
where RawVecInner: UnwindSafe, &'static str: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.