Crates.io | tcp-client |
lib.rs | tcp-client |
version | 0.2.0 |
source | src |
created_at | 2024-01-01 13:38:11.554684 |
updated_at | 2024-03-21 12:21:08.712556 |
description | Convenient client-side TCP service. Based on tcp-handler. |
homepage | |
repository | https://github.com/xuxiaocheng0201/tcp-handler/tree/client |
max_upload_size | |
id | 1085331 |
size | 31,822 |
Read this in other languages: English, 简体中文.
Convenient client-side TCP service. Also see tcp-server for server-side.
Based on tcp-handler.
With complete API document.
Add this to your Cargo.toml
:
[dependencies]
tcp-client = "~0.2"
use tcp_client::define_client;
use tcp_client::errors::Result;
define_client!(pub CommonMyClient, MyClient, "MyTcpApplication");
impl MyClient {
// define your method here.
// example:
async fn my_method(&mut self) -> Result<()> {
self.check_func("my_method").await?;
// ...
Ok(())
}
}
#[tokio::main]
async fn main() {
let mut client = MyClient::connect("127.0.0.1:1234").await.unwrap();
// use client.
// example:
client.my_method().await.unwrap();
}
Versions map to tcp-server with the same protocol. (Recommended for use in conjunction, otherwise unexpected bugs may occur.)
client version | server version |
---|---|
>=0.2.0 | >=0.3.0 |
<0.2.0, >=0.1.0 | <0.3.0 >=0.2.0 |
<0.1.0 | <0.2.0 |
Licensed under either of
at your option.