~ruther/NosSmooth

ref: 6f8822252833b20c112019b294c7f8b3e3cd4b7a NosSmooth/Core/NosSmooth.Packets/IPacketSerializer.cs -rw-r--r-- 1.2 KiB
6f882225 — František Boháček feat: add support for conditional packet attribute 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//
//  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;

/// <summary>
/// Serializer of packets.
/// </summary>
public interface IPacketSerializer
{
    /// <summary>
    /// Serializes the given object to string by appending to the packet string builder.
    /// </summary>
    /// <param name="obj">The packet to serialize.</param>
    /// <returns>A result that may or may not have succeeded.</returns>
    public Result<string> Serialize(IPacket obj);

    /// <summary>
    /// Convert the data from the enumerator to the given type.
    /// </summary>
    /// <param name="packetString">The packet string to deserialize.</param>
    /// <param name="preferredSource">The preferred source to check first. If packet with the given header is not found there, other sources will be checked as well.</param>
    /// <returns>The parsed object or an error.</returns>
    public Result<IPacket> Deserialize(string packetString, PacketSource preferredSource);
}
Do not follow this link