flare_zrpc/
lib.rs

1#[cfg(feature = "bincode")]
2pub mod bincode;
3#[cfg(feature = "bitcode")]
4pub mod bitcode;
5pub mod client;
6mod error;
7mod msg;
8#[cfg(feature = "prost")]
9pub mod prost;
10pub mod server;
11
12pub use client::ZrpcClient;
13pub use error::ZrpcError;
14pub use error::ZrpcServerError;
15pub use error::ZrpcSystemError;
16pub use msg::MsgSerde;
17pub use server::{ZrpcService, ZrpcServiceHander};
18
19#[cfg(test)]
20mod test {}
21
22/// A trait that defines the configuration for ZRPC types. This trait ensures that all associated types
23/// are thread-safe by requiring them to implement `Send` and `Sync`.
24pub trait ZrpcTypeConfig: Send + Sync {
25    /// The input type for the ZRPC configuration.
26    type In: Send + Sync;
27
28    /// The output type for the ZRPC configuration.
29    type Out: Send + Sync;
30
31    /// The error type for the ZRPC configuration.
32    type Err: Send + Sync;
33
34    /// The wrapper type for the ZRPC configuration.
35    type Wrapper: Send + Sync;
36
37    /// The serializer/deserializer for the input type.
38    type InSerde: MsgSerde<Data = Self::In>;
39
40    /// The serializer/deserializer for the output type.
41    type OutSerde: MsgSerde<Data = Self::Out>;
42
43    /// The serializer/deserializer for the error wrapper type.
44    type ErrSerde: MsgSerde<Data = Self::Wrapper>;
45
46    /// Wraps a `ZrpcServerError` into the configured wrapper type.
47    ///
48    /// # Parameters
49    /// - `output`: The `ZrpcServerError` to be wrapped.
50    ///
51    /// # Returns
52    /// A wrapped `ZrpcServerError` of the configured wrapper type.
53    fn wrap(output: ZrpcServerError<Self::Err>) -> Self::Wrapper;
54
55    /// Unwraps a configured wrapper type into a `ZrpcServerError`.
56    ///
57    /// # Parameters
58    /// - `wrapper`: The wrapped `ZrpcServerError` to be unwrapped.
59    ///
60    /// # Returns
61    /// A `ZrpcServerError` of the configured error type.
62    fn unwrap(wrapper: Self::Wrapper) -> ZrpcServerError<Self::Err>;
63}