blob: 26166a79fff6df65a5803cd87eb2bb3313a9bada [file] [log] [blame]
// Copyright 2016 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SRC_LEDGER_LIB_SOCKET_STRINGS_H_
#define SRC_LEDGER_LIB_SOCKET_STRINGS_H_
#include <lib/zx/socket.h>
#include <string>
#include "third_party/abseil-cpp/absl/strings/string_view.h"
namespace ledger {
// Copies the data from |source| into |contents| and returns true on success and
// false on error. In case of I/O error, |contents| holds the data that could
// be read from source before the error occurred.
bool BlockingCopyToString(zx::socket source, std::string* contents);
bool BlockingCopyFromString(absl::string_view source, const zx::socket& destination);
// Copies the string |source| to a temporary socket and returns the
// consumer handle.
zx::socket WriteStringToSocket(absl::string_view source);
} // namespace ledger
#endif // SRC_LEDGER_LIB_SOCKET_STRINGS_H_