using System;
using InABox.Core;

namespace InABox.Rpc
{
    public class RpcQueryTable : ISerializeBinary
    {
        public string Key { get; set; }
        public CoreTable Table { get; set; }
        
        public void SerializeBinary(CoreBinaryWriter writer)
        {
            writer.Write(Key);
            writer.WriteBinaryValue(Table);
        }

        public void DeserializeBinary(CoreBinaryReader reader)
        {
            Key = reader.ReadString();
            Table = reader.ReadBinaryValue<CoreTable>();
        }

        public string FullDescription() => $"{Table.Rows.Count} records / {Table.Columns.Count} columns returned";
    }
}