summaryrefslogtreecommitdiff
path: root/protocol/src/address.rs
blob: 3f927e002d765deebea4bb9f8e17306a5e8d3d1b (plain)
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
use crate::protocol::BasicProtocol;
use std::marker::PhantomData;

/// Upstream, used by Workspace to describe the protocol of UpstreamVault
pub struct Upstream<Protocol>
where
    Protocol: BasicProtocol,
{
    /// Protocol of the target upstream machine
    _p: PhantomData<Protocol>,

    /// Address of the target upstream machine
    #[allow(dead_code)]
    target_address: String,
}

impl<Protocol> Upstream<Protocol>
where
    Protocol: BasicProtocol,
{
    pub fn new(addr: &str) -> Self {
        Upstream {
            _p: PhantomData,
            target_address: addr.to_string(),
        }
    }
}

/// Host, used by Vault to describe its own protocol
pub struct Host<Protocol>
where
    Protocol: BasicProtocol,
{
    /// Protocol of the target upstream machine
    _p: PhantomData<Protocol>,
}

impl<Protocol> Upstream<Protocol>
where
    Protocol: BasicProtocol,
{
    pub fn address(addr: &str) -> Self {
        Upstream {
            _p: PhantomData,
            target_address: addr.to_string(),
        }
    }
}

impl<Protocol> Default for Host<Protocol>
where
    Protocol: BasicProtocol,
{
    fn default() -> Self {
        Self::new()
    }
}

impl<Protocol> Host<Protocol>
where
    Protocol: BasicProtocol,
{
    pub fn new() -> Self {
        Host { _p: PhantomData }
    }
}