RpcWasmClient

Struct RpcWasmClient 

Source
pub struct RpcWasmClient { /* private fields */ }
Expand description

A WASM-compatible RPC client.

Implementations§

Source§

impl RpcWasmClient

Source

pub fn new( emit_callback: impl Fn(Vec<u8>) + Send + Sync + 'static, ) -> RpcWasmClient

Source

pub async fn handle_connect(&self)

Call this from your JavaScript glue code when the WebSocket onopen event fires.

Source

pub async fn read_bytes(&self, bytes: &[u8])

Call this from your JavaScript glue code when the WebSocket receives a message. This now handles both dispatcher reading and endpoint processing of incoming requests.

Source

pub async fn handle_disconnect(&self)

Call this from your JavaScript glue code when the WebSocket’s onclose or onerror event fires.

Source

pub fn is_connected(&self) -> bool

A helper method to check the connection status.

Source

pub fn get_endpoint(&self) -> Arc<RpcServiceEndpoint<()>>

Trait Implementations§

Source§

impl RpcServiceCallerInterface for RpcWasmClient

Source§

fn get_dispatcher(&self) -> Arc<Mutex<RpcDispatcher<'static>>>

Source§

fn get_emit_fn(&self) -> Arc<dyn Fn(Vec<u8>) + Send + Sync>

Source§

fn is_connected(&self) -> bool

Source§

fn set_state_change_handler<'life0, 'async_trait>( &'life0 self, handler: impl 'async_trait + Fn(RpcTransportState) + Send + Sync + 'static, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn call_rpc_streaming<'life0, 'async_trait>( &'life0 self, request: RpcRequest, dynamic_channel_type: DynamicChannelType, ) -> Pin<Box<dyn Future<Output = Result<(RpcStreamEncoder<Box<dyn RpcEmit<Output = ()> + Send + Sync>>, DynamicReceiver), RpcServiceError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Source§

fn call_rpc_buffered<'life0, 'async_trait, T, F>( &'life0 self, request: RpcRequest, decode: F, ) -> Pin<Box<dyn Future<Output = Result<(RpcStreamEncoder<Box<dyn RpcEmit<Output = ()> + Send + Sync>>, Result<T, RpcServiceError>), RpcServiceError>> + Send + 'async_trait>>
where 'life0: 'async_trait, T: Send + 'static + 'async_trait, F: Fn(&[u8]) -> T + Send + Sync + 'static + 'async_trait, Self: 'async_trait,

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more