sea_streamer_socket/
backend.rs

1#[derive(Debug, Copy, Clone, PartialEq, Eq)]
2/// `sea-streamer-socket` Enum for identifying the underlying backend.
3pub enum Backend {
4    #[cfg(feature = "backend-kafka")]
5    Kafka,
6    #[cfg(feature = "backend-redis")]
7    Redis,
8    #[cfg(feature = "backend-stdio")]
9    Stdio,
10    #[cfg(feature = "backend-file")]
11    File,
12}
13
14/// `sea-streamer-socket` methods shared by `Sea*` types.
15pub trait SeaStreamerBackend {
16    #[cfg(feature = "backend-kafka")]
17    type Kafka;
18    #[cfg(feature = "backend-redis")]
19    type Redis;
20    #[cfg(feature = "backend-stdio")]
21    type Stdio;
22    #[cfg(feature = "backend-file")]
23    type File;
24
25    /// Identifies the underlying backend
26    fn backend(&self) -> Backend;
27
28    #[cfg(feature = "backend-kafka")]
29    /// Get the concrete type for the Kafka backend. None if it's another Backend
30    fn get_kafka(&mut self) -> Option<&mut Self::Kafka>;
31
32    #[cfg(feature = "backend-redis")]
33    /// Get the concrete type for the Redis backend. None if it's another Backend
34    fn get_redis(&mut self) -> Option<&mut Self::Redis>;
35
36    #[cfg(feature = "backend-stdio")]
37    /// Get the concrete type for the Stdio backend. None if it's another Backend
38    fn get_stdio(&mut self) -> Option<&mut Self::Stdio>;
39
40    #[cfg(feature = "backend-file")]
41    /// Get the concrete type for the File backend. None if it's another Backend
42    fn get_file(&mut self) -> Option<&mut Self::File>;
43}