blob: e65f659f7c6fb4f3368b53d72efc6f2ba4f4539a (
plain)
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
|
#[doc(hidden)]
pub mod internal;
pub mod channel;
pub mod protocol;
pub mod tcp;
pub mod unix;
mod client_channel;
mod server;
pub use client_channel::ClientChannel;
pub use server::Server;
pub use urpc_macro::service;
use protocol::RpcMessage;
use std::pin::Pin;
use std::future::Future;
use bytes::Bytes;
use futures::{Sink, Stream};
#[derive(Debug, Default)]
pub struct Context;
pub trait Service: Send + Sync + 'static {
fn name() -> &'static str
where
Self: Sized;
fn call(
&self,
method: String,
arguments: Bytes,
) -> Pin<Box<dyn Future<Output = std::io::Result<Bytes>> + Send + '_>>;
}
pub trait Channel:
Stream<Item = std::io::Result<RpcMessage>>
+ Sink<RpcMessage, Error = std::io::Error>
+ Send
+ Unpin
+ 'static
{
}
pub trait Listener<C>: Stream<Item = std::io::Result<C>> + Send + Unpin + 'static
where
C: Channel,
{
}
|