Background and Motivation
This came up while working to add Half support to the CBOR components. While not blocking to my work, these methods would be nice to have for the sake of completeness.
Proposed API
public static class BinaryPrimitives
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Half ReadHalfLittleEndian(ReadOnlySpan<byte> source);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Half ReadHalfBigEndian(ReadOnlySpan<byte> source);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryReadHalfLittleEndian(ReadOnlySpan<byte> source, out Half);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryReadHalfBigEndian(ReadOnlySpan<byte> source, out Half);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void WriteHalfLittleEndian(Span<byte> destination, Half value);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void WriteHalfBigEndian(Span<byte> destination, Half value);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryWriteHalfLittleEndian(Span<byte> destination, Half value);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryWriteHalfBigEndian(Span<byte> destination, Half value);
}
Background and Motivation
This came up while working to add
Halfsupport to the CBOR components. While not blocking to my work, these methods would be nice to have for the sake of completeness.Proposed API