aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..e65f659
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,52 @@
1#[doc(hidden)]
2pub mod internal;
3
4pub mod channel;
5pub mod protocol;
6pub mod tcp;
7pub mod unix;
8
9mod client_channel;
10mod server;
11
12pub use client_channel::ClientChannel;
13pub use server::Server;
14pub use urpc_macro::service;
15
16use protocol::RpcMessage;
17
18use std::pin::Pin;
19use std::future::Future;
20
21use bytes::Bytes;
22use futures::{Sink, Stream};
23
24#[derive(Debug, Default)]
25pub struct Context;
26
27pub trait Service: Send + Sync + 'static {
28 fn name() -> &'static str
29 where
30 Self: Sized;
31
32 fn call(
33 &self,
34 method: String,
35 arguments: Bytes,
36 ) -> Pin<Box<dyn Future<Output = std::io::Result<Bytes>> + Send + '_>>;
37}
38
39pub trait Channel:
40 Stream<Item = std::io::Result<RpcMessage>>
41 + Sink<RpcMessage, Error = std::io::Error>
42 + Send
43 + Unpin
44 + 'static
45{
46}
47
48pub trait Listener<C>: Stream<Item = std::io::Result<C>> + Send + Unpin + 'static
49where
50 C: Channel,
51{
52}