Re-sync with internal repository
[hiphop-php.git] / third-party / thrift / src / thrift / lib / cpp2 / transport / rocket / Types.cpp
blobefda09eeb88f84463672742bda4ac8d729a22cc4
1 /*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <thrift/lib/cpp2/transport/rocket/Types.h>
19 #include <ostream>
21 namespace apache {
22 namespace thrift {
23 namespace rocket {
25 void Payload::append(Payload&& other) {
26 // append() reflects how data is received on the wire: all (possibly
27 // fragmented) metadata arrives first, then the actual data.
28 // If we are appending a payload that has metadata, then the current payload
29 // should not have data.
30 DCHECK(
31 !other.hasNonemptyMetadata() ||
32 metadataSize_ == buffer_->computeChainDataLength());
34 metadataSize_ += other.metadataSize_;
35 metadataAndDataSize_ += other.metadataAndDataSize_;
36 buffer_->prependChain(std::move(other.buffer_));
39 std::ostream& operator<<(std::ostream& os, StreamId streamId) {
40 return os << static_cast<uint32_t>(streamId);
43 } // namespace rocket
44 } // namespace thrift
45 } // namespace apache