~ruther/NosSmooth

ref: 5dc905bc801df41fdd2146ad4dfd47be6acbab22 NosSmooth/Packets/NosSmooth.PacketSerializer.Abstractions/PacketToken.cs -rw-r--r-- 2.0 KiB
5dc905bc — Rutherther feat(game): respond to skill use packet sent from the client to set cooldown early 2 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
//  PacketToken.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 System.Diagnostics.CodeAnalysis;

namespace NosSmooth.PacketSerializer.Abstractions;

/// <summary>
/// The single token from a packet.
/// </summary>
[SuppressMessage
(
    "StyleCop.CSharp.NamingRules",
    "SA1313:Parameter names should begin with lower-case letter",
    Justification = "Record struct creates the underlying properties."
)]
public readonly ref struct PacketToken
{
    /// <summary>
    /// Initializes a new instance of the <see cref="PacketToken"/> struct.
    /// </summary>
    /// <param name="token">The token.</param>
    /// <param name="isLast">Whether this is the last token in the current level.</param>
    /// <param name="encounteredUpperLevel">Whether upper level separator was encountered.</param>
    /// <param name="packetEndReached">Whether the packet end was reached.</param>
    public PacketToken
    (
        ReadOnlySpan<char> token,
        bool? isLast,
        bool? encounteredUpperLevel,
        bool packetEndReached
    )
    {
        Token = token;
        IsLast = isLast;
        EncounteredUpperLevel = encounteredUpperLevel;
        PacketEndReached = packetEndReached;
    }

    /// <summary>
    /// The token.
    /// </summary>
    public ReadOnlySpan<char> Token { get; }

    /// <summary>
    /// Whether the token is last in the current level. Null if it cannot be determined.
    /// </summary>
    public bool? IsLast { get; }

    /// <summary>
    /// Whether the current separator was from an upper stack level than the parent. That could mean some kind of an error if not etc. at the end of parsing a last entry of a list and last entry of a subpacket.
    /// </summary>
    public bool? EncounteredUpperLevel { get; }

    /// <summary>
    /// Whether the packet's end was reached.
    /// </summary>
    public bool PacketEndReached { get; }
}
Do not follow this link