Is it possible to create a struct from a Memory<byte> without copying to an array? Or better yet, create a struct and a Memory<byte> that share the same managed memory?
Reading a C/C++ data structure in C# from a byte array is tantalizingly close but not quite applicable. Memory<T> has a Pin method, but it returns a MemoryHandle instead of a GCHandle.
XY: I'm reading and writing Memory<byte> from a socket, using BinaryPrimitives on spans obtained from slices to get and set individual fields. Representing the Memory as a struct would be nicer.