pub struct RpcClient<Ops, Id = Id64>{ /* private fields */ }Expand description
wRPC client capable of issuing requests and notifications and dispatching
server-side notifications over a WebSocket connection using either the
Borsh or JSON protocol. Ops is the application operation enum and Id
is the message identifier type.
Implementations§
Source§impl<Ops, Id> RpcClient<Ops, Id>
impl<Ops, Id> RpcClient<Ops, Id>
Sourcepub fn new_with_encoding(
encoding: Encoding,
interface: Option<Arc<Interface<Ops>>>,
options: Options<'_>,
config: Option<WebSocketConfig>,
) -> Result<RpcClient<Ops, Id>>
pub fn new_with_encoding( encoding: Encoding, interface: Option<Arc<Interface<Ops>>>, options: Options<'_>, config: Option<WebSocketConfig>, ) -> Result<RpcClient<Ops, Id>>
Create new wRPC client connecting to the supplied URL
This function accepts the Encoding enum argument denoting the underlying
protocol that will be used by the client. Current variants supported
are:
Sourcepub fn new<T>(
interface: Option<Arc<Interface<Ops>>>,
options: Options<'_>,
config: Option<WebSocketConfig>,
) -> Result<RpcClient<Ops, Id>>
pub fn new<T>( interface: Option<Arc<Interface<Ops>>>, options: Options<'_>, config: Option<WebSocketConfig>, ) -> Result<RpcClient<Ops, Id>>
Create new wRPC client connecting to the supplied URL.
This function accepts a generic denoting the underlying protocol that will be used by the client. Current protocols supported are:
Sourcepub async fn connect(&self, options: ConnectOptions) -> ConnectResult<Error>
pub async fn connect(&self, options: ConnectOptions) -> ConnectResult<Error>
Connect to the target wRPC endpoint (websocket address)
Sourcepub fn ctl_multiplexer(&self) -> &Option<Multiplexer<Ctl>>
pub fn ctl_multiplexer(&self) -> &Option<Multiplexer<Ctl>>
Access the optional connect/disconnect Ctl event multiplexer
configured for this client, if any.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Test if the underlying WebSocket is currently open
Sourcepub fn set_url(&self, url: &str) -> Result<()>
pub fn set_url(&self, url: &str) -> Result<()>
Change the URL of the underlying WebSocket
(applicable only to the next connection).
Alternatively, the new URL can be supplied
in the connect() method using ConnectOptions.
Sourcepub fn configure(&self, config: WebSocketConfig)
pub fn configure(&self, config: WebSocketConfig)
Change the configuration of the underlying WebSocket. This method can be used to alter the configuration for the next connection.
Sourcepub fn trigger_abort(&self) -> Result<()>
pub fn trigger_abort(&self) -> Result<()>
Triggers a disconnection on the underlying WebSocket. This is intended for debug purposes only. Can be used to test application reconnection logic.
Trait Implementations§
Auto Trait Implementations§
impl<Ops, Id = Id64> !RefUnwindSafe for RpcClient<Ops, Id>
impl<Ops, Id = Id64> !UnwindSafe for RpcClient<Ops, Id>
impl<Ops, Id> Freeze for RpcClient<Ops, Id>
impl<Ops, Id> Send for RpcClient<Ops, Id>
impl<Ops, Id> Sync for RpcClient<Ops, Id>
impl<Ops, Id> Unpin for RpcClient<Ops, Id>
impl<Ops, Id> UnsafeUnpin for RpcClient<Ops, Id>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.