~ruther/NosSmooth

e48c5f90fdecbc0fc478b7386ea619dac40c85b6 — Rutherther 2 years ago df935e1
feat(packets): accept ReadOnlySpan instead of string in serializer
M Packets/NosSmooth.PacketSerializer/IPacketSerializer.cs => Packets/NosSmooth.PacketSerializer/IPacketSerializer.cs +2 -1
@@ 4,6 4,7 @@
//  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 System;
using NosSmooth.Packets;
using NosSmooth.PacketSerializer.Abstractions.Attributes;
using Remora.Results;


@@ 28,5 29,5 @@ public interface IPacketSerializer
    /// <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);
    public Result<IPacket> Deserialize(ReadOnlySpan<char> packetString, PacketSource preferredSource);
}
\ No newline at end of file

M Packets/NosSmooth.PacketSerializer/PacketSerializer.cs => Packets/NosSmooth.PacketSerializer/PacketSerializer.cs +2 -1
@@ 4,6 4,7 @@
//  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 System;
using NosSmooth.Packets;
using NosSmooth.PacketSerializer.Abstractions;
using NosSmooth.PacketSerializer.Abstractions.Attributes;


@@ 57,7 58,7 @@ public class PacketSerializer : IPacketSerializer
    }

    /// <inheritdoc/>
    public Result<IPacket> Deserialize(string packetString, PacketSource preferredSource)
    public Result<IPacket> Deserialize(ReadOnlySpan<char> packetString, PacketSource preferredSource)
    {
        var packetStringEnumerator = new PacketStringEnumerator(packetString);
        var headerTokenResult = packetStringEnumerator.GetNextToken(out var packetToken);

Do not follow this link