blob: 492c652e0e8d60348aa5d99947c31ae5d5b7cd30 [file] [log] [blame]
// Copyright 2019 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 GARNET_BIN_TRACE_MANAGER_UTIL_H_
#define GARNET_BIN_TRACE_MANAGER_UTIL_H_
#include <lib/zx/socket.h>
namespace tracing {
enum class TransferStatus {
// The transfer is complete.
kComplete,
// An error was detected with the provider, ignore its contribution to
// trace output.
kProviderError,
// Writing of trace data to the receiver failed in an unrecoverable way.
kWriteError,
// The receiver of the transfer went away.
kReceiverDead,
};
// Writes |len| bytes from |buffer| to |socket|. Returns
// TransferStatus::kComplete if the entire buffer has been
// successfully transferred. A return value of
// TransferStatus::kReceiverDead indicates that the peer was closed
// during the transfer.
TransferStatus WriteBufferToSocket(const zx::socket& socket, const void* buffer,
size_t len);
} // namespace tracing
#endif // GARNET_BIN_TRACE_MANAGER_UTIL_H_