servicepoint/crates/servicepoint_binding_cs/ServicePoint/ServicePointExtensions.cs
2024-10-16 22:46:34 +02:00

23 lines
569 B
C#

using System.Diagnostics.CodeAnalysis;
using ServicePoint.BindGen;
namespace ServicePoint;
public static class ServicePointExtensions
{
public static Packet IntoPacket(this Command command)
{
return Packet.FromCommand(command);
}
public static bool TryIntoCommand(this Packet packet, [MaybeNullWhen(false)] out Command command)
{
return Command.TryFromPacket(packet, out command);
}
public unsafe static Span<byte> AsSpan(this ByteSlice slice)
{
return new Span<byte>(slice.start, (int)slice.length);
}
}