1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-09-18 02:06:36 +03:00
Files
mvfst/quic/codec/QuicPacketRebuilder.h
Matt Joras 4601c4bdae Migrate folly::Expected to quic::Expected
Summary:
This migrates the quic code to use quic::Expected instead of folly::Expected. quic::Expected is a vendored wrapper for expected-lite, which itself matches std::expected. std::expected is not available to us, but once it is, we would be able to further simplify to the std version.

This migration is almost entirely mechanical.
 ---
> Generated by [Confucius Code Assist (CCA)](https://www.internalfb.com/wiki/Confucius/Analect/Shared_Analects/Confucius_Code_Assist_(CCA)/)
[Session](https://www.internalfb.com/confucius?session_id=7044a18e-4d22-11f0-afeb-97de80927172&tab=Chat), [Trace](https://www.internalfb.com/confucius?session_id=7044a18e-4d22-11f0-afeb-97de80927172&tab=Trace)
 ---
> Generated by [RACER](https://www.internalfb.com/wiki/RACER_(Risk-Aware_Code_Editing_and_Refactoring)/), powered by [Confucius](https://www.internalfb.com/wiki/Confucius/Analect/Shared_Analects/Confucius_Code_Assist_(CCA)/)
[Session](https://www.internalfb.com/confucius?session_id=1fea6620-4d30-11f0-a206-ad0241db9ec9&tab=Chat), [Trace](https://www.internalfb.com/confucius?session_id=1fea6620-4d30-11f0-a206-ad0241db9ec9&tab=Trace)
[Session](https://www.internalfb.com/confucius?session_id=2bdbabba-505a-11f0-a21b-fb3d40195e00&tab=Chat), [Trace](https://www.internalfb.com/confucius?session_id=2bdbabba-505a-11f0-a21b-fb3d40195e00&tab=Trace)
[Session](https://www.internalfb.com/confucius?session_id=eb689fd2-5114-11f0-ade8-99c0fe2f80f2&tab=Chat), [Trace](https://www.internalfb.com/confucius?session_id=eb689fd2-5114-11f0-ade8-99c0fe2f80f2&tab=Trace)
[Session](https://www.internalfb.com/confucius?session_id=9bc2dcec-51f8-11f0-8604-7bc1f5225a86&tab=Chat), [Trace](https://www.internalfb.com/confucius?session_id=9bc2dcec-51f8-11f0-8604-7bc1f5225a86&tab=Trace)
[Session](https://www.internalfb.com/confucius?session_id=46b187ea-5cdd-11f0-9bab-7b6b886e8a09&tab=Chat), [Trace](https://www.internalfb.com/confucius?session_id=46b187ea-5cdd-11f0-9bab-7b6b886e8a09&tab=Trace)

Reviewed By: kvtsoy

Differential Revision: D76488955

fbshipit-source-id: 92b9cbeac85a28722a6180464b47d84696b1e81b
2025-07-10 15:57:07 -07:00

64 lines
2.1 KiB
C++

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <quic/codec/QuicPacketBuilder.h>
#include <quic/state/StateData.h>
namespace quic {
/**
* A PacketRebuilder is a packet builder that takes in a list of frames, and
* pass them onto a wrapped builder to rebuild the packet. Note that you still
* buildPacket() from the wrapped in builder.
* TODO: The cloning builder only clones stream data that has not already been
* reset or closed. It is possible that a packet may have contained data for
* only closed streams. In that case we would only write out the header.
* This is a waste, so we should do something about this in the future.
*/
class PacketRebuilder {
public:
PacketRebuilder(
PacketBuilderInterface& regularBuilder,
QuicConnectionStateBase& conn);
[[nodiscard]] quic::Expected<Optional<ClonedPacketIdentifier>, QuicError>
rebuildFromPacket(OutstandingPacketWrapper& packet);
// TODO: Same as passing cipherOverhead into the CloningScheduler, this really
// is a sad way to solve the writableBytes problem.
uint64_t getHeaderBytes() const;
private:
/**
* A helper function that takes a OutstandingPacketWrapper that's not
* processed, and return its maybeClonedPacketIdentifier. If this packet has
* never been cloned, then create the maybeClonedPacketIdentifier and add it
* into outstandings.clonedPacketIdentifiers first.
*/
ClonedPacketIdentifier cloneOutstandingPacket(
OutstandingPacketWrapper& packet);
bool retransmittable(const QuicStreamState& stream) const {
return stream.sendState == StreamSendState::Open;
}
const ChainedByteRangeHead* cloneCryptoRetransmissionBuffer(
const WriteCryptoFrame& frame,
const QuicCryptoStream& stream);
const ChainedByteRangeHead* cloneRetransmissionBuffer(
const WriteStreamFrame& frame,
const QuicStreamState* stream);
private:
PacketBuilderInterface& builder_;
QuicConnectionStateBase& conn_;
};
} // namespace quic