#pragma once

#include <softbus_core/models/RawPacket.h>
#include <softbus_core/models/SoftbusTypes.h>

#include <softbus_api/ExecuteCommand.h>

#include <functional>
#include <optional>
#include <string>
#include <vector>

namespace softbus::transport {

enum class WireMessageType {
    RawPacket,
    ExecuteCommand,
    Ack,
    Heartbeat,
    Unknown
};

struct WireMessage {
    WireMessageType type{WireMessageType::Unknown};
    softbus::core::RawPacket rawPacket;
    softbus::api::ExecuteCommand command;
    softbus::core::SoftbusAck ack;
    std::string heartbeatDeviceId;
};

std::string encodeWireMessage(const softbus::core::RawPacket& packet);
std::string encodeWireMessage(const softbus::api::ExecuteCommand& command);
std::string encodeWireMessage(const softbus::core::SoftbusAck& ack);
std::string encodeWireMessage(const std::string& deviceId);
std::optional<WireMessage> decodeWireMessage(const std::string& line);

std::string base64Encode(const uint8_t* data, std::size_t size);
std::vector<uint8_t> base64Decode(const std::string& encoded);

} // namespace softbus::transport
