2024-05-15 20:34:51 +02:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
|
2024-05-25 11:16:37 +02:00
|
|
|
namespace ServicePoint;
|
2024-05-15 20:34:51 +02:00
|
|
|
|
2024-10-19 14:21:50 +02:00
|
|
|
public sealed partial class Packet
|
2024-05-15 20:34:51 +02:00
|
|
|
{
|
2024-10-19 16:04:01 +02:00
|
|
|
public static bool TryLoad(Span<byte> bytes, [MaybeNullWhen(false)] out Packet packet)
|
2024-05-15 20:34:51 +02:00
|
|
|
{
|
|
|
|
unsafe
|
|
|
|
{
|
|
|
|
fixed (byte* bytesPtr = bytes)
|
|
|
|
{
|
2024-10-19 14:21:50 +02:00
|
|
|
packet = TryLoad(bytesPtr, (nuint)bytes.Length);
|
2024-05-15 20:34:51 +02:00
|
|
|
return packet != null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-10-19 14:45:21 +02:00
|
|
|
|
|
|
|
public bool TryIntoCommand([MaybeNullWhen(false)] out Command command)
|
|
|
|
{
|
|
|
|
return Command.TryFromPacket(this, out command);
|
|
|
|
}
|
2024-05-15 20:34:51 +02:00
|
|
|
}
|