public static void Write(this NetBinaryWriter writer, UUID uuid)
        {
            Span <byte> buffer = stackalloc byte[sizeof(ulong) * 2];

            if (writer.Options.IsBigEndian)
            {
                BinaryPrimitives.WriteUInt64BigEndian(buffer, uuid.X);
                BinaryPrimitives.WriteUInt64BigEndian(buffer[sizeof(ulong)..], uuid.Y);
            static void WriteReverse(NetBinaryWriter writer, ReadOnlySpan <int> source)
            {
                Span <int> buffer = stackalloc int[Math.Min(source.Length, 2048 / sizeof(int))];

                int offset = 0;

                do
                {
                    // TODO: vectorize

                    ReadOnlySpan <int> slice = source.Slice(offset, Math.Min(buffer.Length, source.Length - offset));
                    for (int i = 0; i < slice.Length; i++)
                    {
                        buffer[i] = BinaryPrimitives.ReverseEndianness(slice[i]);
                    }

                    WriteBytes(writer, buffer[..slice.Length]);
 public static void Write(this NetBinaryWriter writer, Chat chat)
 {
     writer.Write(chat.Value);
 }
 public static void Write(this NetBinaryWriter writer, Identifier identifier)
 {
     writer.Write((Utf8String)identifier.Value);
 }
 public static void Write(this NetBinaryWriter writer, Position position)
 {
     writer.Write((long)position.Value);
 }
 public static void Write(this NetBinaryWriter writer, Angle angle)
 {
     writer.Write(angle.Value);
 }
예제 #7
0
 public static void Write(this NetBinaryWriter writer, Utf8Identifier identifier)
 {
     writer.Write(identifier.Value);
 }
예제 #8
0
 static void WriteBytes(NetBinaryWriter writer, ReadOnlySpan <int> source)
 {
     writer.Write(MemoryMarshal.AsBytes(source));
 }
예제 #9
0
 public static void Write(this NetBinaryWriter writer, ReadOnlySpan <int> values)
 {
예제 #10
0
        // TODO: vectorize the reversed writers??

        public static void Write(this NetBinaryWriter writer, ReadOnlySpan <sbyte> values)
        {
            writer.Write(MemoryMarshal.Cast <sbyte, byte>(values));
        }