Skip to main content

Serialized

Struct Serialized 

Source
pub struct Serialized<App, RouteSet, Format>
where App: App, RouteSet: Routes<App>, Format: FfiFormat,
{ /* private fields */ }
Expand description

The default route, reproducing the standard Bridge behaviour on top of the EffectRouter.

Effects on this lane are serialized to bytes using Format, registered under an EffectId, and sent to the shell. The shell later calls Serialized::resolve with the id and the serialized response. Events and the view model are likewise exchanged as bytes via Serialized::update and Serialized::view.

This is the primary onboarding path and typically acts as the fall-through arm of the routing closure, handling every effect that isn’t claimed by a more specialised lane.

Serialized keeps a Weak reference to its EffectRouter so that resolving a request and processing an event can advance the runtime and route follow-up effects.

Implementations§

Source§

impl<App, RouteSet, Format> Serialized<App, RouteSet, Format>
where App: App, RouteSet: Routes<App> + Send + Sync + 'static, Format: FfiFormat,

Source

pub fn new(router: Weak<EffectRouter<App, RouteSet>>) -> Self

Create a serialized route attached to router.

Called from your Routes::new implementation with the Weak router handle the trait provides.

Source

pub fn update<'a>(&self, event: &'a [u8]) -> Result<(), BridgeError<Format>>
where App::Event: Deserialize<'a>,

Process a serialized shell event and route any emitted effects.

§Errors

Returns an error if the event bytes could not be deserialized.

§Panics

Panics if the router has been dropped.

Source

pub fn serialize<Eff>( &self, effect: Eff, ) -> Result<Vec<u8>, BridgeError<Format>>
where Eff: EffectFFI,

Park a serialized effect and encode it as request bytes for the shell.

§Errors

Returns an error if the request could not be serialized.

§Panics

Panics if the internal registry lock has been poisoned.

Source

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

Resume a serialized request and route any follow-up effects.

§Errors

Returns an error if the request could not be resumed.

§Panics

Panics if the router has been dropped or the internal registry lock has been poisoned.

Source

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

Serialize the current view model.

§Errors

Returns an error if the view model could not be serialized.

§Panics

Panics if the router has been dropped.

Auto Trait Implementations§

§

impl<App, RouteSet, Format> !Freeze for Serialized<App, RouteSet, Format>

§

impl<App, RouteSet, Format> !RefUnwindSafe for Serialized<App, RouteSet, Format>

§

impl<App, RouteSet, Format> Send for Serialized<App, RouteSet, Format>
where RouteSet: Sync + Send, App: Sync + Send, <App as App>::Model: Send + Sync,

§

impl<App, RouteSet, Format> Sync for Serialized<App, RouteSet, Format>
where RouteSet: Sync + Send, App: Sync + Send, <App as App>::Model: Send + Sync,

§

impl<App, RouteSet, Format> Unpin for Serialized<App, RouteSet, Format>

§

impl<App, RouteSet, Format> UnsafeUnpin for Serialized<App, RouteSet, Format>

§

impl<App, RouteSet, Format> !UnwindSafe for Serialized<App, RouteSet, 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.