summaryrefslogtreecommitdiff
path: root/protocol/src/address.rs
blob: ab49df49db757fe278fa1d965d0cb04c13d87231 (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
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
    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> Host<Protocol>
where
    Protocol: BasicProtocol,
{
    pub fn new() -> Self {
        Host { _p: PhantomData }
    }
}