#pragma once

#include "tcp_buffer.hpp"
#include <cstdint>
#include <netinet/in.h>


namespace tinyrpc {

    struct AbstractData {
        AbstractData() = default;
        virtual ~AbstractData() = default;
    };


    class AbstractCoder {
    public:
        AbstractCoder() = default;
        virtual ~AbstractCoder() = default;

        virtual bool encoder(TcpBuffer& buffer, AbstractData& data) = 0; // 编码

        virtual bool decoder(TcpBuffer& buffer, AbstractData& data) = 0; // 解码

        // virtual std::string getProtocalType() = 0;
    private:

    

    };

    inline int32_t getInt32FromNetByte(char& buf) {
        int32_t tmp;
        memcpy(&tmp, &buf, sizeof(tmp));
        return ntohl(tmp);
    }

}