#pragma once

#ifdef __cplusplus

#include <cstdint>
#include <functional>
#include <string>
#include <vector>

namespace softbus::hardware::interfaces
{

// 面向字节流设备的统一驱动接口：串口 / TCP / UDP 等
class IStreamDriver
{
public:
    using ReadCallback  = std::function<void(const std::vector<std::uint8_t>&)>;
    using ErrorCallback = std::function<void(const std::string& message)>;

    virtual ~IStreamDriver() = default;

    virtual bool Open(const std::string& endpoint) = 0;
    virtual void Close() = 0;

    virtual bool Write(const std::vector<std::uint8_t>& data) = 0;
    virtual bool Write(const std::uint8_t* data, std::size_t size) = 0;

    virtual void SetReadCallback(ReadCallback cb) = 0;
    virtual void SetErrorCallback(ErrorCallback cb) = 0;
};

} // namespace softbus::hardware::interfaces

#endif // __cplusplus

