1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! # tarpc-cat
//!
//! RPC framework built on [`comp-cat-rs`](https://crates.io/crates/comp-cat-rs).
//!
//! Wraps TCP networking with lazy, composable effects. All operations
//! return [`Io<Error, A>`] and nothing executes until `.run()`.
//!
//! ## Quick start
//!
//! Define a service:
//!
//! ```rust,ignore
//! use tarpc_cat::serve::Serve;
//! use tarpc_cat::error::Error;
//! use comp_cat_rs::effect::io::Io;
//! use serde::{Serialize, Deserialize};
//!
//! #[derive(Serialize, Deserialize)]
//! struct Ping(String);
//!
//! #[derive(Serialize, Deserialize)]
//! struct Pong(String);
//!
//! #[derive(Clone)]
//! struct PingService;
//!
//! impl Serve for PingService {
//! type Request = Ping;
//! type Response = Pong;
//!
//! fn handle(&self, request: Ping) -> Io<Error, Pong> {
//! Io::pure(Pong(request.0))
//! }
//! }
//! ```
//!
//! Run the server:
//!
//! ```rust,ignore
//! use tarpc_cat::server::{serve, ListenAddr};
//!
//! let addr = ListenAddr::new("127.0.0.1:9000".parse().unwrap());
//! serve(addr, PingService).run()?;
//! ```
//!
//! Call from a client:
//!
//! ```rust,ignore
//! use tarpc_cat::client::{call, ServerAddr};
//!
//! let addr = ServerAddr::new("127.0.0.1:9000".parse().unwrap());
//! let pong: Pong = call(addr, Ping("hello".into())).run()?;
//! ```
//!
//! [`Io<Error, A>`]: comp_cat_rs::effect::io::Io