mirror of
https://github.com/cccb/servicepoint.git
synced 2025-01-19 02:20:12 +01:00
24 lines
567 B
C#
24 lines
567 B
C#
using System.Diagnostics.CodeAnalysis;
|
|
|
|
namespace ServicePoint;
|
|
|
|
public sealed partial class Packet
|
|
{
|
|
public static bool TryFromBytes(Span<byte> bytes, [MaybeNullWhen(false)] out Packet packet)
|
|
{
|
|
unsafe
|
|
{
|
|
fixed (byte* bytesPtr = bytes)
|
|
{
|
|
packet = TryLoad(bytesPtr, (nuint)bytes.Length);
|
|
return packet != null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public bool TryIntoCommand([MaybeNullWhen(false)] out Command command)
|
|
{
|
|
return Command.TryFromPacket(this, out command);
|
|
}
|
|
}
|