public static byte[] PackMsgToArray <T>(ref T msg, int msgSize, WritePropsDeleg <T> writeProps) where T : struct { using PooledBuffer slice = PooledBuffer.Get(msgSize); int index = 0; writeProps(ref msg, slice.Data, ref index); return(slice.ToArray()); }
public static PooledBuffer PackMsgToBuffer <T>(ref T msg, int msgSize, WritePropsDeleg <T> writeProps) where T : struct { PooledBuffer data = PooledBuffer.Get(msgSize); int index = 0; writeProps(ref msg, data.Data, ref index); return(data); }
public static void PackMsgToStream <T>(ref T msg, Stream destinationStream, int msgSize, WritePropsDeleg <T> writeProps) where T : struct { using PooledBuffer slice = PooledBuffer.Get(msgSize); int index = 0; writeProps(ref msg, slice.Data, ref index); slice.WriteInto(destinationStream); }