github.com/mutagen-io/mutagen@v0.18.0-rc1/pkg/multiplexing/address.go (about) 1 package multiplexing 2 3 import ( 4 "fmt" 5 ) 6 7 // multiplexerAddress implements net.Addr for Multiplexer. 8 type multiplexerAddress struct { 9 // even indicates whether or not this is the even-valued multiplexer. 10 even bool 11 } 12 13 // Network implements net.Addr.Network. 14 func (a *multiplexerAddress) Network() string { 15 return "multiplexed" 16 } 17 18 // String implements net.Addr.String. 19 func (a *multiplexerAddress) String() string { 20 if a.even { 21 return "multiplexer:even" 22 } 23 return "multiplexer:odd" 24 } 25 26 // streamAddress implements net.Addr for Stream. 27 type streamAddress struct { 28 // remote indicates whether or not the address is remote. 29 remote bool 30 // identifier is the stream identifier. 31 identifier uint64 32 } 33 34 // Network implements net.Addr.Network. 35 func (a *streamAddress) Network() string { 36 return "multiplexed" 37 } 38 39 // String implements net.Addr.String. 40 func (a *streamAddress) String() string { 41 if a.remote { 42 return fmt.Sprintf("remote:%d", a.identifier) 43 } else { 44 return fmt.Sprintf("local:%d", a.identifier) 45 } 46 }