// // 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; /// /// The single token from a packet. /// [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 { /// /// Initializes a new instance of the struct. /// /// The token. /// Whether this is the last token in the current level. /// Whether upper level separator was encountered. /// Whether the packet end was reached. public PacketToken ( ReadOnlySpan token, bool? isLast, bool? encounteredUpperLevel, bool packetEndReached ) { Token = token; IsLast = isLast; EncounteredUpperLevel = encounteredUpperLevel; PacketEndReached = packetEndReached; } /// /// The token. /// public ReadOnlySpan Token { get; } /// /// Whether the token is last in the current level. Null if it cannot be determined. /// public bool? IsLast { get; } /// /// 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. /// public bool? EncounteredUpperLevel { get; } /// /// Whether the packet's end was reached. /// public bool PacketEndReached { get; } }