Struct crux_core::bridge::Bridge

source ·
pub struct Bridge<Eff, A>
where Eff: Effect, A: App,
{ /* private fields */ }
Expand description

Bridge is a core wrapper presenting the same interface as the Core but in a serialized form, using bincode as the serialization format.

Implementations§

source§

impl<Eff, A> Bridge<Eff, A>
where Eff: Effect + Send + 'static, A: App,

source

pub fn new(core: Core<Eff, A>) -> Self

Create a new Bridge using the provided core.

source

pub fn process_event(&self, event: &[u8]) -> Vec<u8>
where A::Event: for<'a> Deserialize<'a>,

Receive an event from the shell.

The event is serialized and will be deserialized by the core before it’s passed to your app.

source

pub fn handle_response(&self, id: u32, output: &[u8]) -> Vec<u8>
where A::Event: for<'a> Deserialize<'a>,

Receive a response to a capability request from the shell.

The output is serialized capability output. It will be deserialized by the core. The id MUST match the id of the effect that triggered it, else the core will panic.

source

pub fn view(&self) -> Vec<u8>

Get the current state of the app’s view model (serialized).

Auto Trait Implementations§

§

impl<Eff, A> !Freeze for Bridge<Eff, A>

§

impl<Eff, A> RefUnwindSafe for Bridge<Eff, A>

§

impl<Eff, A> Send for Bridge<Eff, A>
where <A as App>::Capabilities: Send, A: Send, <A as App>::Model: Send,

§

impl<Eff, A> Sync for Bridge<Eff, A>
where <A as App>::Capabilities: Sync, A: Sync, <A as App>::Model: Send + Sync,

§

impl<Eff, A> Unpin for Bridge<Eff, A>
where <A as App>::Capabilities: Unpin, A: Unpin, <A as App>::Model: Unpin, Eff: Unpin, <A as App>::Event: Unpin,

§

impl<Eff, A> UnwindSafe for Bridge<Eff, A>

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.