pub struct Client<C> {
disconnect: AtomicBool,
message_dispatcher: MessageDispatcher,
subscriptions: Arc<Subscriptions>,
send_chan: (Sender<Value>, Receiver<Value>),
task_group: TaskGroup,
config: ClientConfig,
codec: C,
}
Expand description
Represents an RPC client
Fields§
§disconnect: AtomicBool
§message_dispatcher: MessageDispatcher
§subscriptions: Arc<Subscriptions>
§send_chan: (Sender<Value>, Receiver<Value>)
§task_group: TaskGroup
§config: ClientConfig
§codec: C
Implementations§
Source§impl<C> Client<C>where
C: ClonableJsonCodec + 'static,
impl<C> Client<C>where
C: ClonableJsonCodec + 'static,
Sourcepub async fn call<T: Serialize + DeserializeOwned, V: DeserializeOwned>(
&self,
method: &str,
params: T,
) -> Result<V>
pub async fn call<T: Serialize + DeserializeOwned, V: DeserializeOwned>( &self, method: &str, params: T, ) -> Result<V>
Calls the provided method, waits for the response, and returns the result.
Sourcepub async fn subscribe<T: Serialize + DeserializeOwned>(
&self,
method: &str,
params: T,
) -> Result<Arc<Subscription>>
pub async fn subscribe<T: Serialize + DeserializeOwned>( &self, method: &str, params: T, ) -> Result<Arc<Subscription>>
Subscribes to the provided method, waits for the response, and returns the result.
This function sends a subscription request to the specified method
with the given parameters. It waits for the response and returns a
Subscription
.
Sourcepub async fn unsubscribe(
&self,
method: &str,
sub_id: SubscriptionID,
) -> Result<()>
pub async fn unsubscribe( &self, method: &str, sub_id: SubscriptionID, ) -> Result<()>
Unsubscribes from the provided method, waits for the response, and returns the result.
This function sends an unsubscription request for the specified method and subscription ID. It waits for the response to confirm the unsubscription.
async fn send_request<T: Serialize + DeserializeOwned>( &self, method: &str, params: T, ) -> Result<Response>
async fn send(&self, req: Request) -> Result<()>
Sourceasync fn init(config: ClientConfig, codec: C) -> Result<Arc<Self>>
async fn init(config: ClientConfig, codec: C) -> Result<Arc<Self>>
Initializes a new Client
from the provided ClientConfig
.
async fn connect(self: &Arc<Self>) -> Result<Conn<Value, Error>>
fn start_background_loop(self: &Arc<Self>, conn: Conn<Value, Error>)
async fn background_loop( self: Arc<Self>, conn: Conn<Value, Error>, ) -> Result<()>
async fn handle_msg(&self, msg: Value) -> Result<()>
Auto Trait Implementations§
impl<C> !Freeze for Client<C>
impl<C> !RefUnwindSafe for Client<C>
impl<C> Send for Client<C>where
C: Send,
impl<C> Sync for Client<C>where
C: Sync,
impl<C> !Unpin for Client<C>
impl<C> !UnwindSafe for Client<C>
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