Skip to main content

xrpc/
lib.rs

1//! xrpc-rs: High-performance local IPC library for Rust.
2
3pub mod channel;
4pub mod client;
5pub mod codec;
6pub mod discovery;
7pub mod error;
8pub mod lb_client;
9pub mod loadbalancer;
10pub mod message;
11pub mod pool;
12pub mod server;
13pub mod streaming;
14pub mod transport;
15
16// Layer 1: FrameTransport
17pub use transport::arc::{ArcFrameTransport, ZeroCopyTransport};
18pub use transport::channel::{ChannelConfig, ChannelFrameTransport};
19pub use transport::shared_memory::{RetryPolicy, SharedMemoryConfig, SharedMemoryFrameTransport};
20pub use transport::tcp::{TcpConfig, TcpFrameTransport, TcpFrameTransportListener};
21pub use transport::{FrameTransport, TransportStats, spawn_weak_loop};
22
23#[cfg(unix)]
24pub use transport::unix::{UnixConfig, UnixFrameTransport, UnixFrameTransportListener};
25
26// Layer 2: Channel
27pub use channel::message::{MessageChannel, MessageChannelAdapter};
28pub use channel::serde::SerdeChannel;
29pub use channel::typed::TypedChannel;
30
31// Layer 3: RPC
32pub use client::{CallOptions, CallTimeout, RpcClient, RpcClientHandle};
33pub use pool::{ConnectionPool, PoolConfig, PoolGuard};
34pub use server::{
35    FnHandler, FnStreamHandler, Handler, RpcServer, ServerHandle, ServerStreamSender,
36    StreamHandler, TypedHandler, TypedStreamHandler,
37};
38pub use streaming::{StreamId, StreamManager, StreamReceiver, StreamSender, next_stream_id};
39
40// Layer 4: Discovery & Load Balancing
41pub use discovery::{DiscoveryEvent, DnsDiscovery, Endpoint, ServiceDiscovery, StaticDiscovery};
42pub use lb_client::{ClientFactory, LoadBalancedClient};
43pub use loadbalancer::{
44    LeastConnections, LoadBalanceStrategy, LoadBalancer, LoadBalancerConfig, LoadBalancerHandle,
45    Random, RoundRobin, ScoreBased, ServerHealth, ServerState, ServerWeight, WeightedRoundRobin,
46};
47
48// Codec
49#[cfg(feature = "codec-cbor")]
50pub use codec::CborCodec;
51#[cfg(feature = "codec-messagepack")]
52pub use codec::MessagePackCodec;
53#[cfg(feature = "codec-postcard")]
54pub use codec::PostcardCodec;
55pub use codec::{BincodeCodec, Codec, JsonCodec};
56
57// Error types
58pub use error::{Result, RpcError, TransportError, TransportResult};
59
60// Message types
61pub use message::Message;
62pub use message::types::{MessageId, MessageType};
63
64// Deprecated aliases for backward compatibility
65#[deprecated(since = "0.2.0", note = "Use ArcFrameTransport instead")]
66pub type ArcTransport = ArcFrameTransport;
67
68#[deprecated(since = "0.2.0", note = "Use ChannelFrameTransport instead")]
69pub type ChannelTransport = ChannelFrameTransport;
70
71#[deprecated(since = "0.2.0", note = "Use SharedMemoryFrameTransport instead")]
72pub type SharedMemoryTransport = SharedMemoryFrameTransport;
73
74#[deprecated(since = "0.2.0", note = "Use TcpFrameTransport instead")]
75pub type TcpTransport = TcpFrameTransport;
76
77#[deprecated(since = "0.2.0", note = "Use TcpFrameTransportListener instead")]
78pub type TcpTransportListener = TcpFrameTransportListener;
79
80#[cfg(unix)]
81#[deprecated(since = "0.2.0", note = "Use UnixFrameTransport instead")]
82pub type UnixSocketTransport = UnixFrameTransport;
83
84#[cfg(unix)]
85#[deprecated(since = "0.2.0", note = "Use UnixFrameTransportListener instead")]
86pub type UnixSocketListener = UnixFrameTransportListener;
87
88#[deprecated(since = "0.2.0", note = "Use MessageChannelAdapter instead")]
89pub type MessageTransportAdapter<F, C = BincodeCodec> = MessageChannelAdapter<F, C>;
90
91#[deprecated(since = "0.2.0", note = "Use SerdeChannel instead")]
92pub type RawTransport<F> = SerdeChannel<F, BincodeCodec>;