1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-11-12 08:41:01 +03:00

Make Quic packet header encoding reusable

Summary:
The encoding logic is the same no matter what builder and what IOBuf
manipulater we use. Make these functions reusable.

This requires the QuicInteger encode function to support both BufAppender and
BufWriter. Note that the template is on a callable object. Because later on we
will also need to support wrapped memcpy that isn't a member function.

Reviewed By: mjoras

Differential Revision: D20781979

fbshipit-source-id: 1b8cbdfd7580132c113b12687f932d47207a7cce
This commit is contained in:
Yang Chi
2020-04-06 13:55:28 -07:00
committed by Facebook GitHub Bot
parent 44d9adbf0a
commit c0707bf996
9 changed files with 119 additions and 132 deletions

View File

@@ -93,7 +93,8 @@ void setupCommonExpects(MockQuicPacketBuilder& pktBuilder) {
EXPECT_CALL(pktBuilder, write(_))
.WillRepeatedly(Invoke([&](const QuicInteger& quicInteger) {
quicInteger.encode(pktBuilder.appender_);
quicInteger.encode(
[&](auto val) { pktBuilder.appender_.writeBE(val); });
pktBuilder.remaining_ -= quicInteger.getSize();
}));
}