tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

optional_blob_encoding.h (1497B)


      1 /*
      2 *  Copyright (c) 2023 The WebRTC project authors. All Rights Reserved.
      3 *
      4 *  Use of this source code is governed by a BSD-style license
      5 *  that can be found in the LICENSE file in the root of the source
      6 *  tree. An additional intellectual property rights grant can be found
      7 *  in the file PATENTS.  All contributing project authors may
      8 *  be found in the AUTHORS file in the root of the source tree.
      9 */
     10 
     11 #ifndef LOGGING_RTC_EVENT_LOG_ENCODER_OPTIONAL_BLOB_ENCODING_H_
     12 #define LOGGING_RTC_EVENT_LOG_ENCODER_OPTIONAL_BLOB_ENCODING_H_
     13 
     14 #include <stddef.h>
     15 
     16 #include <optional>
     17 #include <string>
     18 #include <vector>
     19 
     20 #include "absl/strings/string_view.h"
     21 
     22 namespace webrtc {
     23 
     24 // Encode a sequence of optional strings, whose length is not known to be
     25 // discernable from the blob itself (i.e. without being transmitted OOB),
     26 // in a way that would allow us to separate them again on the decoding side.
     27 // EncodeOptionalBlobs() may not fail but may return an empty string
     28 std::string EncodeOptionalBlobs(
     29    const std::vector<std::optional<std::string>>& blobs);
     30 
     31 // Calling DecodeOptionalBlobs() on an empty string, or with `num_of_blobs` set
     32 // to 0, is an error. DecodeOptionalBlobs() returns an empty vector if it fails,
     33 // which can happen if `encoded_blobs` is corrupted.
     34 std::vector<std::optional<std::string>> DecodeOptionalBlobs(
     35    absl::string_view encoded_blobs,
     36    size_t num_of_blobs);
     37 
     38 }  // namespace webrtc
     39 
     40 #endif  // LOGGING_RTC_EVENT_LOG_ENCODER_OPTIONAL_BLOB_ENCODING_H_