macro_rules! define_client {
($vis: vis $client: ident, $tcp_client: ident, $identifier: literal) => { ... };
(raw, $vis: vis $client: ident, $tcp_client: ident, $identifier: literal) => { ... };
(compress, $vis: vis $client: ident, $tcp_client: ident, $identifier: literal) => { ... };
(encrypt, $vis: vis $client: ident, $tcp_client: ident, $identifier: literal) => { ... };
(compress_encrypt, $vis: vis $client: ident, $tcp_client: ident, $identifier: literal) => { ... };
(@@define $protocol: ident, $inner: ident, $vis: vis $client: ident, $tcp_client: ident, $identifier: literal) => { ... };
}
Expand description
The main macro provided by this crate.
ยงExample
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();
}