uint32_t BinaryProtocolWriter::writeSerializedData(
    const std::unique_ptr<IOBuf>& buf) {
  if (!buf) {
    return 0;
  }
  // TODO: insert() just chains IOBufs together. Consider copying data to the
  // output buffer as it was already preallocated with the correct size.
  auto clone = buf->clone();
  if (sharing_ != SHARE_EXTERNAL_BUFFER) {
    clone->makeManaged();
  }
  out_.insert(std::move(clone));
  return buf->computeChainDataLength();
}
uint32_t BinaryProtocolWriter::writeSerializedData(
    const std::unique_ptr<IOBuf>& buf) {
  if (!buf) {
    return 0;
  }
   
   
  auto clone = buf->clone();
  if (sharing_ != SHARE_EXTERNAL_BUFFER) {
    clone->makeManaged();
  }
  out_.insert(std::move(clone));
  return buf->computeChainDataLength();
}