//
// IPacketSerializer.cs
//
// Copyright (c) František Boháček. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using NosSmooth.Packets.Attributes;
using NosSmooth.Packets.Errors;
using NosSmooth.Packets.Packets;
using Remora.Results;
namespace NosSmooth.Packets;
///
/// Serializer of packets.
///
public interface IPacketSerializer
{
///
/// Serializes the given object to string by appending to the packet string builder.
///
/// The packet to serialize.
/// A result that may or may not have succeeded.
public Result Serialize(IPacket obj);
///
/// Convert the data from the enumerator to the given type.
///
/// The packet string to deserialize.
/// The preferred source to check first. If packet with the given header is not found there, other sources will be checked as well.
/// The parsed object or an error.
public Result Deserialize(string packetString, PacketSource preferredSource);
}