pub struct RpcWasmClient { /* private fields */ }Expand description
A WASM-compatible RPC client.
Implementations§
Source§impl RpcWasmClient
impl RpcWasmClient
pub fn new( emit_callback: impl Fn(Vec<u8>) + Send + Sync + 'static, ) -> RpcWasmClient
Sourcepub async fn handle_connect(&self)
pub async fn handle_connect(&self)
Call this from your JavaScript glue code when the WebSocket onopen event fires.
Sourcepub async fn read_bytes(&self, bytes: &[u8])
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.
Sourcepub async fn handle_disconnect(&self)
pub async fn handle_disconnect(&self)
Call this from your JavaScript glue code when the WebSocket’s onclose or onerror event fires.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
A helper method to check the connection status.
pub fn get_endpoint(&self) -> Arc<RpcServiceEndpoint<()>>
Trait Implementations§
Source§impl RpcServiceCallerInterface for RpcWasmClient
impl RpcServiceCallerInterface for RpcWasmClient
fn get_dispatcher(&self) -> Arc<Mutex<RpcDispatcher<'static>>>
fn get_emit_fn(&self) -> Arc<dyn Fn(Vec<u8>) + Send + Sync>
fn is_connected(&self) -> bool
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,
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,
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>>
Auto Trait Implementations§
impl Freeze for RpcWasmClient
impl !RefUnwindSafe for RpcWasmClient
impl Send for RpcWasmClient
impl Sync for RpcWasmClient
impl Unpin for RpcWasmClient
impl !UnwindSafe for RpcWasmClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more