Skip to content

Latest commit

 

History

History
29 lines (20 loc) · 1016 Bytes

File metadata and controls

29 lines (20 loc) · 1016 Bytes

Abstract

UnsafeUnmanagedStructFormatters (de)serialize the blittable value(s) directly. They are very performant but unstable against the endian.

You should be careful not to share the encoded byte[] among the different endian environments.

Supported types (T where T : unamanaged)

  • TUnsafeUnmanagedStructFormatter<T>
  • T[]UnsafeUnmanagedStructArrayFormatter<T>
  • Memory<T>UnsafeUnmanagedStructMemoryFormatter<T>
  • ReadOnlyMemory<T>UnsafeUnmanagedStructReadOnlyMemoryFormatter<T>
  • ReadOnlySequence<T>UnsafeUnmanagedStructReadOnlySequenceFormatter<T>

Usage

var resolver = MessagePack.Resolvers.CompositeResolver.Create(
    new[] { new UnsafeUnmanagedStructFormatter<Matrix4x4>(typeCode: 96) },
    new[] { MessagePack.Resolvers.StandardResolver.Instance });

The constructor takes 1 sbyte value. The sbyte value is the extension type code embedded in serialized byte sequence.

When will this feature become official?

  • Requests are needed.