From cfa6df32c0f56ba7bb82a0ca47fa0f26884c3de7 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Thu, 29 Oct 2020 10:36:01 +0100 Subject: [PATCH] Add Datagram.len --- quic/datagram.nim | 4 ++++ tests/quic/testUdp.nim | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/quic/datagram.nim b/quic/datagram.nim index e2b7cab..1327311 100644 --- a/quic/datagram.nim +++ b/quic/datagram.nim @@ -5,3 +5,7 @@ type data*: seq[byte] ecn*: ECN DatagramBuffer* = openArray[byte] + + +proc len*(datagram: Datagram): int = + datagram.data.len diff --git a/tests/quic/testUdp.nim b/tests/quic/testUdp.nim index b600803..19580a6 100644 --- a/tests/quic/testUdp.nim +++ b/tests/quic/testUdp.nim @@ -7,7 +7,7 @@ suite "udp": test "writes packets to datagrams": let client = newClientConnection(zeroAddress, zeroAddress) - check client.write().data.len > 0 + check client.write().len > 0 test "reads packets from datagram": let client = newClientConnection(zeroAddress, zeroAddress)