Skip to main content

Bridge

Struct Bridge 

Source
pub struct Bridge<Next, Format>
where Next: Layer, Format: FfiFormat,
{ /* private fields */ }
Expand description

FFI Bridge with support for wrapping a middleware stack

Implementations§

Source§

impl<Next, Format> Bridge<Next, Format>
where Next: Layer, Next::Event: for<'a> Deserialize<'a>, Next::Effect: EffectFFI, Format: FfiFormat,

Source

pub fn new<F>(next: Next, effect_callback: F) -> Self
where F: Fn(Result<Vec<u8>, BridgeError<Format>>) + Send + Sync + 'static,

Typically, you would would use Layer::bridge to construct a Bridge instance

Source

pub fn update( &self, event_bytes: &[u8], requests_out: &mut Vec<u8>, ) -> Result<(), BridgeError<Format>>

Send a serialized event to the core

§Errors

Returns an BridgeError when any of the (de)serialization fails

Source

pub fn resolve( &self, id: EffectId, output: &[u8], requests_out: &mut Vec<u8>, ) -> Result<(), BridgeError<Format>>

Resolve a requested effect, providing the output to the core

§Errors

Returns a BridgeError when the effect fails to resolve, or any of the (de)serialization fails.

Source

pub fn view(&self, view_out: &mut Vec<u8>) -> Result<(), BridgeError<Format>>
where Next::ViewModel: Serialize,

Get the latest view model

§Errors

Returns an BridgeError when any of the (de)serialization fails

Auto Trait Implementations§

§

impl<Next, Format> Freeze for Bridge<Next, Format>
where Next: Freeze,

§

impl<Next, Format> !RefUnwindSafe for Bridge<Next, Format>

§

impl<Next, Format> Send for Bridge<Next, Format>
where Format: Send,

§

impl<Next, Format> Sync for Bridge<Next, Format>
where Format: Sync,

§

impl<Next, Format> Unpin for Bridge<Next, Format>
where Next: Unpin, Format: Unpin,

§

impl<Next, Format> UnsafeUnpin for Bridge<Next, Format>
where Next: UnsafeUnpin,

§

impl<Next, Format> !UnwindSafe for Bridge<Next, Format>

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.