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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! Factories for specific sets of protocols.

pub mod latest {
    use crate::*;

    /// The latest version of all protocols
    ///
    /// # Examples
    /// ```
    /// use runng::{
    ///     factory::latest::ProtocolFactory,
    /// };
    /// let factory = ProtocolFactory::default();
    /// let publisher = factory.publisher_open();
    /// ```
    #[derive(Debug, Default)]
    pub struct ProtocolFactory {}

    impl ProtocolFactory {
        pub fn bus_open(&self) -> Result<protocol::Bus0> {
            protocol::Bus0::open()
        }
        pub fn requester_open(&self) -> Result<protocol::Req0> {
            protocol::Req0::open()
        }
        pub fn replier_open(&self) -> Result<protocol::Rep0> {
            protocol::Rep0::open()
        }
        pub fn publisher_open(&self) -> Result<protocol::Pub0> {
            protocol::Pub0::open()
        }
        pub fn subscriber_open(&self) -> Result<protocol::Sub0> {
            protocol::Sub0::open()
        }
        pub fn pusher_open(&self) -> Result<protocol::Push0> {
            protocol::Push0::open()
        }
        pub fn puller_open(&self) -> Result<protocol::Pull0> {
            protocol::Pull0::open()
        }
        pub fn pair_open(&self) -> Result<protocol::Pair1> {
            protocol::Pair1::open()
        }
    }
}

pub mod compat {
    use crate::*;

    /// Protocols compatible with nanomsg
    #[derive(Debug, Default)]
    pub struct ProtocolFactory {}

    impl ProtocolFactory {
        pub fn bus_open(&self) -> Result<protocol::Bus0> {
            protocol::Bus0::open()
        }
        pub fn requester_open(&self) -> Result<protocol::Req0> {
            protocol::Req0::open()
        }
        pub fn replier_open(&self) -> Result<protocol::Rep0> {
            protocol::Rep0::open()
        }
        pub fn publisher_open(&self) -> Result<protocol::Pub0> {
            protocol::Pub0::open()
        }
        pub fn subscriber_open(&self) -> Result<protocol::Sub0> {
            protocol::Sub0::open()
        }
        pub fn pusher_open(&self) -> Result<protocol::Push0> {
            protocol::Push0::open()
        }
        pub fn puller_open(&self) -> Result<protocol::Pull0> {
            protocol::Pull0::open()
        }
        pub fn pair_open(&self) -> Result<protocol::Pair0> {
            protocol::Pair0::open()
        }
    }
}