diff options
| author | diogo464 <[email protected]> | 2025-07-16 10:46:41 +0100 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-07-16 10:46:41 +0100 |
| commit | f319d7ab5278a3cfb43d38875d81c28cc2dce1e1 (patch) | |
| tree | cb161fd990643e267bbc373fb09ccd7b689a23b5 /src/lib.rs | |
Initial commit - extracted urpc from monorepo
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 52 |
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)] | ||
| 2 | pub mod internal; | ||
| 3 | |||
| 4 | pub mod channel; | ||
| 5 | pub mod protocol; | ||
| 6 | pub mod tcp; | ||
| 7 | pub mod unix; | ||
| 8 | |||
| 9 | mod client_channel; | ||
| 10 | mod server; | ||
| 11 | |||
| 12 | pub use client_channel::ClientChannel; | ||
| 13 | pub use server::Server; | ||
| 14 | pub use urpc_macro::service; | ||
| 15 | |||
| 16 | use protocol::RpcMessage; | ||
| 17 | |||
| 18 | use std::pin::Pin; | ||
| 19 | use std::future::Future; | ||
| 20 | |||
| 21 | use bytes::Bytes; | ||
| 22 | use futures::{Sink, Stream}; | ||
| 23 | |||
| 24 | #[derive(Debug, Default)] | ||
| 25 | pub struct Context; | ||
| 26 | |||
| 27 | pub 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 | |||
| 39 | pub 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 | |||
| 48 | pub trait Listener<C>: Stream<Item = std::io::Result<C>> + Send + Unpin + 'static | ||
| 49 | where | ||
| 50 | C: Channel, | ||
| 51 | { | ||
| 52 | } | ||
