2021-10-06 09:30:38 +00:00
|
|
|
|
|
|
|
import
|
2023-05-18 10:20:44 +00:00
|
|
|
preserves
|
2021-10-06 09:30:38 +00:00
|
|
|
|
|
|
|
type
|
2021-09-24 19:25:47 +00:00
|
|
|
TcpLocal* {.preservesRecord: "tcp-local".} = object
|
2021-10-06 09:30:38 +00:00
|
|
|
`host`*: string
|
2022-07-08 12:49:24 +00:00
|
|
|
`port`*: BiggestInt
|
2021-10-06 09:30:38 +00:00
|
|
|
|
2023-12-31 17:15:06 +00:00
|
|
|
TcpPeerInfo* {.preservesRecord: "tcp-peer".} = object
|
2024-01-07 22:11:59 +00:00
|
|
|
`handle`* {.preservesEmbedded.}: EmbeddedRef
|
2021-10-06 09:30:38 +00:00
|
|
|
`local`*: TcpLocal
|
|
|
|
`remote`*: TcpRemote
|
|
|
|
|
2021-09-24 19:25:47 +00:00
|
|
|
TcpRemote* {.preservesRecord: "tcp-remote".} = object
|
|
|
|
`host`*: string
|
2022-07-08 12:49:24 +00:00
|
|
|
`port`*: BiggestInt
|
2021-09-24 19:25:47 +00:00
|
|
|
|
2023-12-31 17:15:06 +00:00
|
|
|
proc `$`*(x: TcpLocal | TcpPeerInfo | TcpRemote): string =
|
|
|
|
`$`(toPreserves(x))
|
2021-10-06 09:30:38 +00:00
|
|
|
|
2023-12-31 17:15:06 +00:00
|
|
|
proc encode*(x: TcpLocal | TcpPeerInfo | TcpRemote): seq[byte] =
|
|
|
|
encode(toPreserves(x))
|