TupleEncoder
Namespace: SnowBank.Data.Tuples.Binary · class
Helper class to encode and decode tuples to and from binary buffers
Remarks
This class is intended for implementors of tuples, and should not be called directly by application code!
Methods
DecodeFirst
static T1 DecodeFirst<T1>(ReadOnlySpan<byte> packedKey, int? expectedSize)
Unpack a tuple and only return its first element
packedKey— Slice that should be entirely parsable as a tuple of at least 1 elementexpectedSize— If notnull, verifies that the tuple has the expected size
Returns: Decoded value of the first item in the tuple
static (T1, T2) DecodeFirst<T1, T2>(ReadOnlySpan<byte> packedKey, int? expectedSize)
Unpack a tuple and only return its first 2 elements
packedKey— Slice that should be entirely parsable as a tuple of at least 2 elementsexpectedSize— If notnull, verifies that the tuple has the expected size
Returns: Decoded values of the first two elements in the tuple
static (T1, T2, T3) DecodeFirst<T1, T2, T3>(ReadOnlySpan<byte> packedKey, int? expectedSize)
Unpack a tuple and only return its first 3 elements
packedKey— Slice that should be entirely parsable as a tuple of at least 3 elementsexpectedSize— If notnull, verifies that the tuple has the expected size
Returns: Decoded values of the first three elements in the tuple
static (T1, T2, T3, T4) DecodeFirst<T1, T2, T3, T4>(ReadOnlySpan<byte> packedKey, int? expectedSize)
Unpack a tuple and only return its first 4 elements
packedKey— Slice that should be entirely parsable as a tuple of at least 4 elementsexpectedSize— If notnull, verifies that the tuple has the expected size
Returns: Decoded values of the first four elements in the tuple
DecodeKey
static void DecodeKey<T1>(ref TupleReader reader, out (T1) tuple)
Unpacks the value of a singleton tuple
reader— Slice that should contain the packed representation of a tuple with a single elementtuple— Receives the decoded tuple
Throws an exception if the tuple is empty or has more than one element.
static void DecodeKey<T1>(ref TupleReader reader, out T1 item1)
Unpacks the value of a singleton tuple
static void DecodeKey<T1, T2>(ref TupleReader reader, out (T1, T2) tuple)
Unpacks a key containing two elements
reader— Slice that should contain the packed representation of a tuple with two elementstuple— Receives the decoded tuple
Throws an exception if the tuple is empty of has more than two elements.
static void DecodeKey<T1, T2, T3>(ref TupleReader reader, out (T1, T2, T3) tuple)
Unpacks a key containing three elements
reader— Slice that should contain the packed representation of a tuple with three elementstuple— Receives the decoded tuple
Throws an exception if the tuple is empty of has more than three elements.
static void DecodeKey<T1, T2, T3, T4>(ref TupleReader reader, out (T1, T2, T3, T4) tuple)
Unpacks a key containing four elements
reader— Slice that should contain the packed representation of a tuple with four elementstuple— Receives the decoded tuple
Throws an exception if the tuple is empty of has more than four elements.
static void DecodeKey<T1, T2, T3, T4, T5>(ref TupleReader reader, out (T1, T2, T3, T4, T5) tuple)
Unpacks a key containing five elements
reader— Slice that should contain the packed representation of a tuple with five elementstuple— Receives the decoded tuple
Throws an exception if the tuple is empty of has more than five elements.
static void DecodeKey<T1, T2, T3, T4, T5, T6>(ref TupleReader reader, out (T1, T2, T3, T4, T5, T6) tuple)
Unpacks a key containing six elements
reader— Slice that should contain the packed representation of a tuple with six elementstuple— Receives the decoded tuple
Throws an exception if the tuple is empty of has more than six elements.
static void DecodeKey<T1, T2, T3, T4, T5, T6, T7>(ref TupleReader reader, out (T1, T2, T3, T4, T5, T6, T7) tuple)
Unpacks a key containing six elements
reader— Slice that should contain the packed representation of a tuple with six elementstuple— Receives the decoded tuple
Throws an exception if the tuple is empty of has more than six elements.
static void DecodeKey<T1, T2, T3, T4, T5, T6, T7, T8>(ref TupleReader reader, out (T1, T2, T3, T4, T5, T6, T7, (T8)) tuple)
Unpacks a key containing eight elements
reader— Slice that should contain the packed representation of a tuple with six elementstuple— Receives the decoded tuple
Throws an exception if the tuple is empty of has more than six elements.
static void DecodeKey<T1, T2, T3, T4, T5, T6, T7, T8, T9>(ref TupleReader reader, out (T1, T2, T3, T4, T5, T6, T7, (T8, T9)) tuple)
Unpacks a key containing eight elements
reader— Slice that should contain the packed representation of a tuple with six elementstuple— Receives the decoded tuple
Throws an exception if the tuple is empty of has more than six elements.
static void DecodeKey<T1, T2>(ref TupleReader reader, out T1 item1, out T2 item2)
static void DecodeKey<T1, T2, T3>(ref TupleReader reader, out T1 item1, out T2 item2, out T3 item3)
static void DecodeKey<T1, T2, T3, T4>(ref TupleReader reader, out T1 item1, out T2 item2, out T3 item3, out T4 item4)
static void DecodeKey<T1, T2, T3, T4, T5>(ref TupleReader reader, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5)
static void DecodeKey<T1, T2, T3, T4, T5, T6>(ref TupleReader reader, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6)
static void DecodeKey<T1, T2, T3, T4, T5, T6, T7>(ref TupleReader reader, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7)
static void DecodeKey<T1, T2, T3, T4, T5, T6, T7, T8>(ref TupleReader reader, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8)
static void DecodeKey<T1, T2, T3, T4, T5, T6, T7, T8, T9>(ref TupleReader reader, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8, out T9 item9)
DecodeLast
static T1 DecodeLast<T1>(ReadOnlySpan<byte> packedKey, int? expectedSize)
Unpack a tuple and only return its last element
packedKey— Slice that should be entirely parsable as a tuple of at least one elementexpectedSize— If notnull, verifies that the tuple has the expected size
Returns: Decoded value of the last item in the tuple
static (T1, T2) DecodeLast<T1, T2>(ReadOnlySpan<byte> packedKey, int? expectedSize)
Unpack a tuple and only return its last 2 elements
packedKey— Slice that should be entirely parsable as a tuple of at least 2 elementsexpectedSize— If notnull, verifies that the tuple has the expected size
Returns: Decoded values of the last two elements in the tuple
static (T1, T2, T3) DecodeLast<T1, T2, T3>(ReadOnlySpan<byte> packedKey, int? expectedSize)
Unpack a tuple and only return its last 3 elements
packedKey— Slice that should be entirely parsable as a tuple of at least 3 elementsexpectedSize— If notnull, verifies that the tuple has the expected size
Returns: Decoded values of the last three elements in the tuple
static (T1, T2, T3, T4) DecodeLast<T1, T2, T3, T4>(ReadOnlySpan<byte> packedKey, int? expectedSize)
Unpack a tuple and only return its last 4 elements
packedKey— Slice that should be entirely parsable as a tuple of at least 4 elementsexpectedSize— If notnull, verifies that the tuple has the expected size
Returns: Decoded values of the last four elements in the tuple
EncodeKey
static Slice EncodeKey<T1>(ReadOnlySpan<byte> prefix, T1 value)
Efficiently concatenates a prefix with the packed representation of a 1-tuple
static Slice EncodeKey<T1, T2>(ReadOnlySpan<byte> prefix, T1 value1, T2 value2)
Efficiently concatenates a prefix with the packed representation of a 2-tuple
static Slice EncodeKey<T1, T2, T3>(ReadOnlySpan<byte> prefix, T1 value1, T2 value2, T3 value3)
Efficiently concatenates a prefix with the packed representation of a 3-tuple
static Slice EncodeKey<T1, T2, T3, T4>(ReadOnlySpan<byte> prefix, T1 value1, T2 value2, T3 value3, T4 value4)
Efficiently concatenates a prefix with the packed representation of a 4-tuple
static Slice EncodeKey<T1, T2, T3, T4, T5>(ReadOnlySpan<byte> prefix, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5)
Efficiently concatenates a prefix with the packed representation of a 5-tuple
static Slice EncodeKey<T1, T2, T3, T4, T5, T6>(ReadOnlySpan<byte> prefix, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6)
Efficiently concatenates a prefix with the packed representation of a 6-tuple
static Slice EncodeKey<T1, T2, T3, T4, T5, T6, T7>(ReadOnlySpan<byte> prefix, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7)
Efficiently concatenates a prefix with the packed representation of a 7-tuple
static Slice EncodeKey<T1, T2, T3, T4, T5, T6, T7, T8>(ReadOnlySpan<byte> prefix, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8)
Efficiently concatenates a prefix with the packed representation of an 8-tuple
static Slice EncodeKey<T1, T2, T3, T4, T5, T6, T7, T8, T9>(ReadOnlySpan<byte> prefix, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9)
Efficiently concatenates a prefix with the packed representation of an 9-tuple
Pack
static Slice Pack<TTuple>(in TTuple tuple)
Packs a tuple into a slice
tuple— Tuple that must be serialized into a binary slice
static Slice[] Pack<TTuple>(TTuple[] tuples)
Packs an array of N-tuples, all sharing the same buffer
tuples— Sequence of N-tuples to pack
Returns: Array containing the buffer segment of each packed tuple
BatchPack([ ("Foo", 1), ("Foo", 2) ]) => [ "\x02Foo\x00\x15\x01", "\x02Foo\x00\x15\x02" ]
static Slice[] Pack<TTuple>(ReadOnlySpan<TTuple> tuples)
Packs an array of N-tuples, all sharing the same buffer
tuples— Sequence of N-tuples to pack
Returns: Array containing the buffer segment of each packed tuple
BatchPack([ ("Foo", 1), ("Foo", 2) ]) => [ "\x02Foo\x00\x15\x01", "\x02Foo\x00\x15\x02" ]
static SliceOwner Pack<TTuple>(in TTuple tuple, ArrayPool<byte> pool)
Packs a tuple into a slice
tuple— Tuple that must be serialized into a binary slicepool— Pool used to rent the buffers
static Slice Pack<TTuple>(ReadOnlySpan<byte> prefix, TTuple tuple)
Efficiently concatenates a prefix with the packed representation of a tuple
static Slice[] Pack<TTuple>(ReadOnlySpan<byte> prefix, TTuple[] tuples)
Packs an array of N-tuples, all sharing the same buffer
prefix— Common prefix added to all the tuplestuples— Sequence of N-tuples to pack
Returns: Array containing the buffer segment of each packed tuple
BatchPack("abc", [ ("Foo", 1), ("Foo", 2) ]) => [ "abc\x02Foo\x00\x15\x01", "abc\x02Foo\x00\x15\x02" ]
static Slice[] Pack<TTuple>(ReadOnlySpan<byte> prefix, ReadOnlySpan<TTuple> tuples)
Packs an array of N-tuples, all sharing the same buffer
prefix— Common prefix added to all the tuplestuples— Sequence of N-tuples to pack
Returns: Array containing the buffer segment of each packed tuple
BatchPack("abc", [ ("Foo", 1), ("Foo", 2) ]) => [ "abc\x02Foo\x00\x15\x01", "abc\x02Foo\x00\x15\x02" ]
static Slice[] Pack<TTuple>(ReadOnlySpan<byte> prefix, IEnumerable<TTuple> tuples)
Packs a sequence of N-tuples, all sharing the same buffer
prefix— Common prefix added to all the tuplestuples— Sequence of N-tuples to pack
Returns: Array containing the buffer segment of each packed tuple
BatchPack("abc", [ ("Foo", 1), ("Foo", 2) ]) => [ "abc\x02Foo\x00\x15\x01", "abc\x02Foo\x00\x15\x02" ]
static Slice Pack<T1>(ReadOnlySpan<byte> prefix, in (T1) items)
Efficiently concatenates a prefix with the packed representation of a 1-tuple
static Slice Pack<T1, T2>(ReadOnlySpan<byte> prefix, in (T1, T2) items)
Efficiently concatenates a prefix with the packed representation of a 2-tuple
static Slice Pack<T1, T2, T3>(ReadOnlySpan<byte> prefix, in (T1, T2, T3) items)
Efficiently concatenates a prefix with the packed representation of a 3-tuple
static Slice Pack<T1, T2, T3, T4>(ReadOnlySpan<byte> prefix, in (T1, T2, T3, T4) items)
Efficiently concatenates a prefix with the packed representation of a 4-tuple
static Slice Pack<T1, T2, T3, T4, T5>(ReadOnlySpan<byte> prefix, in (T1, T2, T3, T4, T5) items)
Efficiently concatenates a prefix with the packed representation of a 5-tuple
static Slice Pack<T1, T2, T3, T4, T5, T6>(ReadOnlySpan<byte> prefix, in (T1, T2, T3, T4, T5, T6) items)
Efficiently concatenates a prefix with the packed representation of a 6-tuple
static Slice Pack<T1, T2, T3, T4, T5, T6, T7>(ReadOnlySpan<byte> prefix, in (T1, T2, T3, T4, T5, T6, T7) items)
Efficiently concatenates a prefix with the packed representation of a 7-tuple
static Slice Pack<T1, T2, T3, T4, T5, T6, T7, T8>(ReadOnlySpan<byte> prefix, in (T1, T2, T3, T4, T5, T6, T7, (T8)) items)
Efficiently concatenates a prefix with the packed representation of an 8-tuple
static Slice Pack<T1, T2, T3, T4, T5, T6, T7, T8, T9>(ReadOnlySpan<byte> prefix, in (T1, T2, T3, T4, T5, T6, T7, (T8, T9)) items)
Efficiently concatenates a prefix with the packed representation of an 9-tuple
static Slice Pack<T1>(ReadOnlySpan<byte> prefix, in STuple<T1> tuple)
Packs a 1-tuple directly into a slice
static Slice Pack<T1, T2>(ReadOnlySpan<byte> prefix, in STuple<T1, T2> tuple)
Packs a 2-tuple directly into a slice
static Slice Pack<T1, T2, T3>(ReadOnlySpan<byte> prefix, in STuple<T1, T2, T3> tuple)
Packs a 3-tuple directly into a slice
static Slice Pack<T1, T2, T3, T4>(ReadOnlySpan<byte> prefix, in STuple<T1, T2, T3, T4> tuple)
Packs a 4-tuple directly into a slice
static Slice Pack<T1, T2, T3, T4, T5>(ReadOnlySpan<byte> prefix, in STuple<T1, T2, T3, T4, T5> tuple)
Packs a 5-tuple directly into a slice
static Slice Pack<T1, T2, T3, T4, T5, T6>(ReadOnlySpan<byte> prefix, in STuple<T1, T2, T3, T4, T5, T6> tuple)
Packs a 6-tuple directly into a slice
static Slice Pack<T1, T2, T3, T4, T5, T6, T7>(ReadOnlySpan<byte> prefix, in STuple<T1, T2, T3, T4, T5, T6, T7> tuple)
Packs a 7-tuple directly into a slice
static Slice Pack<T1, T2, T3, T4, T5, T6, T7, T8>(ReadOnlySpan<byte> prefix, in STuple<T1, T2, T3, T4, T5, T6, T7, T8> tuple)
Packs a 8-tuple directly into a slice
static Slice[] Pack<TElement, TTuple>(ReadOnlySpan<byte> prefix, TElement[] elements, Func<TElement, TTuple> transform)
static Slice[] Pack<TElement, TTuple>(ReadOnlySpan<byte> prefix, ReadOnlySpan<TElement> elements, Func<TElement, TTuple> transform)
static Slice[] Pack<TElement, TTuple>(ReadOnlySpan<byte> prefix, IEnumerable<TElement> elements, Func<TElement, TTuple> transform)
static SliceOwner Pack<T1>(ArrayPool<byte> pool, ReadOnlySpan<byte> prefix, in (T1) items)
Efficiently concatenates a prefix with the packed representation of a 1-tuple
static SliceOwner Pack<T1>(ArrayPool<byte> pool, ReadOnlySpan<byte> prefix, in STuple<T1> items)
Efficiently concatenates a prefix with the packed representation of a 1-tuple
static SliceOwner Pack<T1, T2>(ArrayPool<byte> pool, ReadOnlySpan<byte> prefix, in STuple<T1, T2> items)
Efficiently concatenates a prefix with the packed representation of a 2-tuple
static SliceOwner Pack<T1, T2>(ArrayPool<byte> pool, ReadOnlySpan<byte> prefix, in (T1, T2) items)
Efficiently concatenates a prefix with the packed representation of a 2-tuple
static SliceOwner Pack<T1, T2, T3>(ArrayPool<byte> pool, ReadOnlySpan<byte> prefix, in STuple<T1, T2, T3> items)
Efficiently concatenates a prefix with the packed representation of a 3-tuple
static SliceOwner Pack<T1, T2, T3>(ArrayPool<byte> pool, ReadOnlySpan<byte> prefix, in (T1, T2, T3) items)
Efficiently concatenates a prefix with the packed representation of a 3-tuple
static SliceOwner Pack<T1, T2, T3, T4>(ArrayPool<byte> pool, ReadOnlySpan<byte> prefix, in STuple<T1, T2, T3, T4> items)
Efficiently concatenates a prefix with the packed representation of a 4-tuple
static SliceOwner Pack<T1, T2, T3, T4>(ArrayPool<byte> pool, ReadOnlySpan<byte> prefix, in (T1, T2, T3, T4) items)
Efficiently concatenates a prefix with the packed representation of a 4-tuple
static SliceOwner Pack<T1, T2, T3, T4, T5>(ArrayPool<byte> pool, ReadOnlySpan<byte> prefix, in STuple<T1, T2, T3, T4, T5> items)
Efficiently concatenates a prefix with the packed representation of a 5-tuple
static SliceOwner Pack<T1, T2, T3, T4, T5>(ArrayPool<byte> pool, ReadOnlySpan<byte> prefix, in (T1, T2, T3, T4, T5) items)
Efficiently concatenates a prefix with the packed representation of a 5-tuple
static SliceOwner Pack<T1, T2, T3, T4, T5, T6>(ArrayPool<byte> pool, ReadOnlySpan<byte> prefix, in STuple<T1, T2, T3, T4, T5, T6> items)
Efficiently concatenates a prefix with the packed representation of a 6-tuple
static SliceOwner Pack<T1, T2, T3, T4, T5, T6>(ArrayPool<byte> pool, ReadOnlySpan<byte> prefix, in (T1, T2, T3, T4, T5, T6) items)
Efficiently concatenates a prefix with the packed representation of a 6-tuple
static SliceOwner Pack<T1, T2, T3, T4, T5, T6, T7>(ArrayPool<byte> pool, ReadOnlySpan<byte> prefix, in STuple<T1, T2, T3, T4, T5, T6, T7> items)
Efficiently concatenates a prefix with the packed representation of a 7-tuple
static SliceOwner Pack<T1, T2, T3, T4, T5, T6, T7>(ArrayPool<byte> pool, ReadOnlySpan<byte> prefix, in (T1, T2, T3, T4, T5, T6, T7) items)
Efficiently concatenates a prefix with the packed representation of a 7-tuple
static SliceOwner Pack<T1, T2, T3, T4, T5, T6, T7, T8>(ArrayPool<byte> pool, ReadOnlySpan<byte> prefix, in STuple<T1, T2, T3, T4, T5, T6, T7, T8> items)
Efficiently concatenates a prefix with the packed representation of an 8-tuple
static SliceOwner Pack<T1, T2, T3, T4, T5, T6, T7, T8>(ArrayPool<byte> pool, ReadOnlySpan<byte> prefix, in (T1, T2, T3, T4, T5, T6, T7, (T8)) items)
Efficiently concatenates a prefix with the packed representation of an 8-tuple
TryDecodeFirst
static bool TryDecodeFirst<T1>(ReadOnlySpan<byte> packedKey, int? expectedSize, out T1 item1)
Unpack a tuple and only return its last element
packedKey— Slice that should be entirely parsable as a tuple of at least one elementexpectedSize— If notnull, verifies that the tuple has the expected sizeitem1— Receives the decoded value of the last item
Returns: Decoded value of the last item in the tuple
static bool TryDecodeFirst<T1, T2>(ReadOnlySpan<byte> packedKey, int? expectedSize, out T1 item1, out T2 item2)
Unpack a tuple and only return its last 2 elements
packedKey— Slice that should be entirely parsable as a tuple of at least 2 elementsexpectedSize— If notnull, verifies that the tuple has the expected sizeitem1— First decoded elementitem2— Second decoded element
Returns: Decoded values of the last 2 elements in the tuple
static bool TryDecodeFirst<T1, T2, T3>(ReadOnlySpan<byte> packedKey, int? expectedSize, out T1 item1, out T2 item2, out T3 item3)
Unpack a tuple and only return its last 3 elements
packedKey— Slice that should be entirely parsable as a tuple of at least 3 elementsexpectedSize— If notnull, verifies that the tuple has the expected sizeitem1— First decoded elementitem2— Second decoded elementitem3— Third decoded element
Returns: Decoded values of the last 3 elements in the tuple
static bool TryDecodeFirst<T1, T2, T3, T4>(ReadOnlySpan<byte> packedKey, int? expectedSize, out T1 item1, out T2 item2, out T3 item3, out T4 item4)
Unpack a tuple and only return its last 4 elements
packedKey— Slice that should be entirely parsable as a tuple of at least 4 elementsexpectedSize— If notnull, verifies that the tuple has the expected sizeitem1— First decoded elementitem2— Second decoded elementitem3— Third decoded elementitem4— Fourth decoded element
Returns: Decoded values of the last 4 elements in the tuple
TryDecodeKey
static bool TryDecodeKey<TKey>(ref TupleReader reader, out TKey key, out Exception error)
Unpacks the value of a singleton tuple
reader— Slice that should contain the packed representation of a tuple with a single elementkey— Receives the decoded value
TryDecodeLast
static bool TryDecodeLast<T1>(ReadOnlySpan<byte> packedKey, int? expectedSize, out T1 item1)
Unpack a tuple and only return its last element
packedKey— Slice that should be entirely parsable as a tuple of at least one elementexpectedSize— If notnull, verifies that the tuple has the expected sizeitem1— Receives the decoded value of the last item
Returns: Decoded value of the last item in the tuple
static bool TryDecodeLast<T1, T2>(ReadOnlySpan<byte> packedKey, int? expectedSize, out T1 item1, out T2 item2)
Unpack a tuple and only return its last 2 elements
packedKey— Slice that should be entirely parsable as a tuple of at least 2 elementsexpectedSize— If notnull, verifies that the tuple has the expected sizeitem1— First decoded elementitem2— Second decoded element
Returns: Decoded values of the last 2 elements in the tuple
static bool TryDecodeLast<T1, T2, T3>(ReadOnlySpan<byte> packedKey, int? expectedSize, out T1 item1, out T2 item2, out T3 item3)
Unpack a tuple and only return its last 3 elements
packedKey— Slice that should be entirely parsable as a tuple of at least 3 elementsexpectedSize— If notnull, verifies that the tuple has the expected sizeitem1— First decoded elementitem2— Second decoded elementitem3— Third decoded element
Returns: Decoded values of the last 3 elements in the tuple
static bool TryDecodeLast<T1, T2, T3, T4>(ReadOnlySpan<byte> packedKey, int? expectedSize, out T1 item1, out T2 item2, out T3 item3, out T4 item4)
Unpack a tuple and only return its last 4 elements
packedKey— Slice that should be entirely parsable as a tuple of at least 4 elementsexpectedSize— If notnull, verifies that the tuple has the expected sizeitem1— First decoded elementitem2— Second decoded elementitem3— Third decoded elementitem4— Fourth decoded element
Returns: Decoded values of the last 4 elements in the tuple
TryDecodeNext
static bool TryDecodeNext<T>(ref TupleReader reader, out T value, out Exception error)
Unpacks the next item in the tuple, and advance the cursor
reader— Reader positioned at the start of the next item to readvalue— If decoding succeeded, receives the decoded value.error— If non-null, error that describes why the decoding failed
Returns: true if the decoded succeeded (and value receives the decoded value); otherwise, false if the tuple has reached the end or the next item is malformed.
TryEncodeKey
static bool TryEncodeKey<T1>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, T1 item1)
Pack a 1-tuple directly into a destination buffer
static bool TryEncodeKey<T1, T2>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, T1 item1, T2 item2)
Pack a 2-tuple directly into a destination buffer
static bool TryEncodeKey<T1, T2, T3>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, T1 item1, T2 item2, T3 item3)
Pack a 3-tuple directly into a destination buffer
static bool TryEncodeKey<T1, T2, T3, T4>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, T1 item1, T2 item2, T3 item3, T4 item4)
Pack a 4-tuple directly into a destination buffer
static bool TryEncodeKey<T1, T2, T3, T4, T5>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, T1 item1, T2 item2, T3 item3, T4 item4, T5 item5)
Pack a 5-tuple directly into a destination buffer
static bool TryEncodeKey<T1, T2, T3, T4, T5, T6>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6)
Pack a 6-tuple directly into a destination buffer
static bool TryEncodeKey<T1, T2, T3, T4, T5, T6, T7>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7)
Pack a 7-tuple directly into a destination buffer
static bool TryEncodeKey<T1, T2, T3, T4, T5, T6, T7, T8>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, T8 item8)
Pack an 8-tuple directly into a destination buffer
static bool TryEncodeKey<T1, T2, T3, T4, T5, T6, T7, T8, T9>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, T8 item8, T9 item9)
Pack an 8-tuple directly into a destination buffer
TryGetSizeHint
static bool TryGetSizeHint<T>(in T item, bool embedded, out int sizeHint)
TryPackTo
static bool TryPackTo<TTuple>(Span<byte> destination, out int bytesWritten, in TTuple tuple)
Packs a tuple into a slice
static bool TryPackTo<TTuple>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, TTuple tuple)
Efficiently concatenates a prefix with the packed representation of a tuple
static bool TryPackTo<T1>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, in STuple<T1> items)
Efficiently concatenates a prefix with the packed representation of a 1-tuple
static bool TryPackTo<T1>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, in (T1) items)
Efficiently concatenates a prefix with the packed representation of a 1-tuple
static bool TryPackTo<T1, T2>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, in STuple<T1, T2> items)
Efficiently concatenates a prefix with the packed representation of a 2-tuple
static bool TryPackTo<T1, T2>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, in (T1, T2) items)
Efficiently concatenates a prefix with the packed representation of a 2-tuple
static bool TryPackTo<T1, T2, T3>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, in STuple<T1, T2, T3> items)
Efficiently concatenates a prefix with the packed representation of a 3-tuple
static bool TryPackTo<T1, T2, T3>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, in (T1, T2, T3) items)
Efficiently concatenates a prefix with the packed representation of a 3-tuple
static bool TryPackTo<T1, T2, T3, T4>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, in STuple<T1, T2, T3, T4> items)
Efficiently concatenates a prefix with the packed representation of a 4-tuple
static bool TryPackTo<T1, T2, T3, T4>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, in (T1, T2, T3, T4) items)
Efficiently concatenates a prefix with the packed representation of a 4-tuple
static bool TryPackTo<T1, T2, T3, T4, T5>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, in STuple<T1, T2, T3, T4, T5> items)
Efficiently concatenates a prefix with the packed representation of a 5-tuple
static bool TryPackTo<T1, T2, T3, T4, T5>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, in (T1, T2, T3, T4, T5) items)
Efficiently concatenates a prefix with the packed representation of a 5-tuple
static bool TryPackTo<T1, T2, T3, T4, T5, T6>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, in STuple<T1, T2, T3, T4, T5, T6> items)
Efficiently concatenates a prefix with the packed representation of a 6-tuple
static bool TryPackTo<T1, T2, T3, T4, T5, T6>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, in (T1, T2, T3, T4, T5, T6) items)
Efficiently concatenates a prefix with the packed representation of a 6-tuple
static bool TryPackTo<T1, T2, T3, T4, T5, T6, T7>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, in STuple<T1, T2, T3, T4, T5, T6, T7> items)
Efficiently concatenates a prefix with the packed representation of a 7-tuple
static bool TryPackTo<T1, T2, T3, T4, T5, T6, T7>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, in (T1, T2, T3, T4, T5, T6, T7) items)
Efficiently concatenates a prefix with the packed representation of a 7-tuple
static bool TryPackTo<T1, T2, T3, T4, T5, T6, T7, T8>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, in STuple<T1, T2, T3, T4, T5, T6, T7, T8> items)
Efficiently concatenates a prefix with the packed representation of an 8-tuple
static bool TryPackTo<T1, T2, T3, T4, T5, T6, T7, T8>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, in (T1, T2, T3, T4, T5, T6, T7, (T8)) items)
Efficiently concatenates a prefix with the packed representation of an 8-tuple
static bool TryPackTo<T1, T2, T3, T4, T5, T6, T7, T8, T9>(Span<byte> destination, out int bytesWritten, ReadOnlySpan<byte> prefix, in (T1, T2, T3, T4, T5, T6, T7, (T8, T9)) items)
Efficiently concatenates a prefix with the packed representation of an 9-tuple
TrySkipNext
static bool TrySkipNext(ref TupleReader reader, out Exception error)
Skips the next item in the tuple, and advance the cursor
reader— Reader positioned at the start of the item to skip
Returns: true if an item was successfully skipped; otherwise, false if the tuple has reached the end or the next item is malformed.
TryWriteKeysTo
static bool TryWriteKeysTo<T1, T2>(ref TupleSpanWriter writer, T1 item1, T2 item2)
Packs a 2-tuple directly into a slice
static bool TryWriteKeysTo<T1, T2, T3>(ref TupleSpanWriter writer, T1 item1, T2 item2, T3 item3)
Packs a 3-tuple directly into a slice
static bool TryWriteKeysTo<T1, T2, T3, T4>(ref TupleSpanWriter writer, T1 item1, T2 item2, T3 item3, T4 item4)
Packs a 4-tuple directly into a slice