TuPack

Namespace: SnowBank.Data.Tuples · class

Tuple Binary Encoding

Properties

IsReflectionSupported

static bool IsReflectionSupported { get; }

Whether the runtime reflection path that builds encoders and decoders for uncommon tuple element types is available.

Defaults to true. Well-known element types packed through the typed key API (int, long, string, Guid, bool, and the other types with a compile-time fast path) never use this path, so they are unaffected by the switch. Only uncommon element types, and any value packed through the untyped or boxed object path, use the reflection-based builder.

An application that publishes trimmed or Native AoT can set the MSBuild feature SnowBank.Data.Tuples.TuPack.IsReflectionSupported=false (or the matching runtime config switch): the trimmer then substitutes this property to false and removes the reflection-based builder, so a consumer that only uses well-known element types builds with no trim warnings. With reflection off, an exotic element type (Nullable of a non-well-known type, a nested tuple, a ValueTuple, or a boxed object) throws NotSupportedException instead of building a reflection-based encoder that the trimmer may have removed.

Methods

CountItems

static int CountItems(ReadOnlySpan<byte> packedKey)

Counts the number of items in a packed tuple, without decoding them

  • packedKey — Binary key containing a previously packed tuple

Returns: Number of items in the tuple, so a caller can size a Range buffer for the buffered Unpack/TryUnpack overloads

DecodeFirst

static T1 DecodeFirst<T1>(Slice packedKey, int? expectedSize = null)

Unpack a tuple and only return its first element

  • packedKey — Slice that should be entirely parsable as a tuple of at least 1 element
  • expectedSize — If not null, verifies that the tuple has the expected size

Returns: Decoded value of the first item in the tuple

static T1 DecodeFirst<T1>(ReadOnlySpan<byte> packedKey, int? expectedSize = null)

Unpack a tuple and only return its first element

  • packedKey — Slice that should be entirely parsable as a tuple of at least 1 element
  • expectedSize — If not null, verifies that the tuple has the expected size

Returns: Decoded value of the first item in the tuple

static (T1, T2) DecodeFirst<T1, T2>(Slice packedKey, int? expectedSize = null)

Unpack a tuple and only return its first 2 elements

  • packedKey — Slice that should be entirely parsable as a tuple of at least 2 elements
  • expectedSize — If not null, verifies that the tuple has the expected size

Returns: Decoded values of the first two elements in the tuple

static (T1, T2) DecodeFirst<T1, T2>(ReadOnlySpan<byte> packedKey, int? expectedSize = null)

Unpack a tuple and only return its first 2 elements

  • packedKey — Slice that should be entirely parsable as a tuple of at least 2 elements
  • expectedSize — If not null, 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>(Slice packedKey, int? expectedSize = null)

Unpack a tuple and only return its first 3 elements

  • packedKey — Slice that should be entirely parsable as a tuple of at least 3 elements
  • expectedSize — If not null, verifies that the tuple has the expected size

Returns: Decoded values of the first three elements in the tuple

static (T1, T2, T3) DecodeFirst<T1, T2, T3>(ReadOnlySpan<byte> packedKey, int? expectedSize = null)

Unpack a tuple and only return its first 3 elements

  • packedKey — Slice that should be entirely parsable as a tuple of at least 3 elements
  • expectedSize — If not null, 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>(Slice packedKey, int? expectedSize = null)

Unpack a tuple and only return its first 4 elements

  • packedKey — Slice that should be entirely parsable as a tuple of at least 4 elements
  • expectedSize — If not null, verifies that the tuple has the expected size

Returns: Decoded values of the first four elements in the tuple

static (T1, T2, T3, T4) DecodeFirst<T1, T2, T3, T4>(ReadOnlySpan<byte> packedKey, int? expectedSize = null)

Unpack a tuple and only return its first 4 elements

  • packedKey — Slice that should be entirely parsable as a tuple of at least 4 elements
  • expectedSize — If not null, verifies that the tuple has the expected size

Returns: Decoded values of the first four elements in the tuple

DecodeKey

static T1 DecodeKey<T1>(Slice packedKey)

Unpack the value of a singleton tuple

  • packedKey — Slice that should contain the packed representation of a tuple with a single element

Returns: Decoded value of the only item in the tuple. Throws an exception if the tuple is empty, or has more than one element.

static T1 DecodeKey<T1>(ReadOnlySpan<byte> packedKey)

Unpack the value of a singleton tuple

  • packedKey — Slice that should contain the packed representation of a tuple with a single element

Returns: Decoded value of the only item in the tuple. Throws an exception if the tuple is empty, or has more than one element.

static (T1, T2) DecodeKey<T1, T2>(Slice packedKey)

Unpack a key containing two elements

  • packedKey — Slice that should contain the packed representation of a tuple with two elements

Returns: Decoded value of the elements int the tuple. Throws an exception if the tuple is empty, or has more than two elements.

static (T1, T2) DecodeKey<T1, T2>(ReadOnlySpan<byte> packedKey)

Unpack a key containing two elements

  • packedKey — Slice that should contain the packed representation of a tuple with two elements

Returns: Decoded value of the elements int the tuple. Throws an exception if the tuple is empty, or has more than two elements.

static (T1, T2, T3) DecodeKey<T1, T2, T3>(Slice packedKey)

Unpack a key containing three elements

  • packedKey — Slice that should contain the packed representation of a tuple with three elements

Returns: Decoded value of the elements int the tuple. Throws an exception if the tuple is empty, or has more than three elements.

static (T1, T2, T3) DecodeKey<T1, T2, T3>(ReadOnlySpan<byte> packedKey)

Unpack a key containing three elements

  • packedKey — Slice that should contain the packed representation of a tuple with three elements

Returns: Decoded value of the elements int the tuple. Throws an exception if the tuple is empty, or has more than three elements.

static (T1, T2, T3, T4) DecodeKey<T1, T2, T3, T4>(Slice packedKey)

Unpack a key containing four elements

  • packedKey — Slice that should contain the packed representation of a tuple with four elements

Returns: Decoded value of the elements int the tuple. Throws an exception if the tuple is empty, or has more than four elements.

static (T1, T2, T3, T4) DecodeKey<T1, T2, T3, T4>(ReadOnlySpan<byte> packedKey)

Unpack a key containing four elements

  • packedKey — Slice that should contain the packed representation of a tuple with four elements

Returns: Decoded value of the elements int the tuple. Throws an exception if the tuple is empty, or has more than four elements.

static (T1, T2, T3, T4, T5) DecodeKey<T1, T2, T3, T4, T5>(Slice packedKey)

Unpack a key containing five elements

  • packedKey — Slice that should contain the packed representation of a tuple with five elements

Returns: Decoded value of the elements int the tuple. Throws an exception if the tuple is empty, or has more than five elements.

static (T1, T2, T3, T4, T5) DecodeKey<T1, T2, T3, T4, T5>(ReadOnlySpan<byte> packedKey)

Unpack a key containing five elements

  • packedKey — Slice that should contain the packed representation of a tuple with five elements

Returns: Decoded value of the elements int the tuple. Throws an exception if the tuple is empty, or has more than five elements.

static (T1, T2, T3, T4, T5, T6) DecodeKey<T1, T2, T3, T4, T5, T6>(Slice packedKey)

Unpack a key containing six elements

  • packedKey — Slice that should contain the packed representation of a tuple with six elements

Returns: Decoded value of the elements int the tuple. Throws an exception if the tuple is empty, or has more than six elements.

static (T1, T2, T3, T4, T5, T6) DecodeKey<T1, T2, T3, T4, T5, T6>(ReadOnlySpan<byte> packedKey)

Unpack a key containing six elements

  • packedKey — Slice that should contain the packed representation of a tuple with six elements

Returns: Decoded value of the elements int the tuple. Throws an exception if the tuple is empty, or has more than six elements.

static (T1, T2, T3, T4, T5, T6, T7) DecodeKey<T1, T2, T3, T4, T5, T6, T7>(Slice packedKey)

Unpack a key containing seven elements

  • packedKey — Slice that should contain the packed representation of a tuple with seven elements

Returns: Decoded value of the elements int the tuple. Throws an exception if the tuple is empty, or has more than seven elements.

static (T1, T2, T3, T4, T5, T6, T7) DecodeKey<T1, T2, T3, T4, T5, T6, T7>(ReadOnlySpan<byte> packedKey)

Unpack a key containing seven elements

  • packedKey — Slice that should contain the packed representation of a tuple with seven elements

Returns: Decoded value of the elements int the tuple. Throws an exception if the tuple is empty, or has more than seven elements.

static (T1, T2, T3, T4, T5, T6, T7, (T8)) DecodeKey<T1, T2, T3, T4, T5, T6, T7, T8>(Slice packedKey)

Unpack a key containing eight elements

  • packedKey — Slice that should contain the packed representation of a tuple with eight elements

Returns: Decoded value of the elements int the tuple. Throws an exception if the tuple is empty, or has more than eight elements.

static (T1, T2, T3, T4, T5, T6, T7, (T8)) DecodeKey<T1, T2, T3, T4, T5, T6, T7, T8>(ReadOnlySpan<byte> packedKey)

Unpack a key containing eight elements

  • packedKey — Slice that should contain the packed representation of a tuple with eight elements

Returns: Decoded value of the elements int the tuple. Throws an exception if the tuple is empty, or has more than eight elements.

static (T1, T2, T3, T4, T5, T6, T7, (T8, T9)) DecodeKey<T1, T2, T3, T4, T5, T6, T7, T8, T9>(Slice packedKey)

Unpack a key containing nine elements

  • packedKey — Slice that should contain the packed representation of a tuple with eight elements

Returns: Decoded value of the elements int the tuple. Throws an exception if the tuple is empty, or has more than eight elements.

static (T1, T2, T3, T4, T5, T6, T7, (T8, T9)) DecodeKey<T1, T2, T3, T4, T5, T6, T7, T8, T9>(ReadOnlySpan<byte> packedKey)

Unpack a key containing nine elements

  • packedKey — Slice that should contain the packed representation of a tuple with eight elements

Returns: Decoded value of the elements int the tuple. Throws an exception if the tuple is empty, or has more than eight elements.

static void DecodeKey<T1>(Slice packedKey, out T1 item1)

Unpack the value of a singleton tuple

  • packedKey — Slice that should contain the packed representation of a tuple with a single element
  • item1 — Decoded value of the only item in the tuple.

static void DecodeKey<T1>(ReadOnlySpan<byte> packedKey, out T1 item1)

Unpack the value of a singleton tuple

  • packedKey — Slice that should contain the packed representation of a tuple with a single element
  • item1 — Decoded value of the only item in the tuple.

static void DecodeKey<T1, T2>(Slice packedKey, out T1 item1, out T2 item2)

Unpack a key containing two elements

  • packedKey — Slice that should contain the packed representation of a tuple with two elements
  • item1 — Decoded value of the 1st element in the tuple.
  • item2 — Decoded value of the 2nd element in the tuple.

static void DecodeKey<T1, T2>(ReadOnlySpan<byte> packedKey, out T1 item1, out T2 item2)

Unpack a key containing two elements

  • packedKey — Slice that should contain the packed representation of a tuple with two elements
  • item1 — Decoded value of the 1st element in the tuple.
  • item2 — Decoded value of the 2nd element in the tuple.

static void DecodeKey<T1, T2, T3>(Slice packedKey, out T1 item1, out T2 item2, out T3 item3)

Unpack a key containing three elements

  • packedKey — Slice that should contain the packed representation of a tuple with three elements
  • item1 — Decoded value of the 1st element in the tuple.
  • item2 — Decoded value of the 2nd element in the tuple.
  • item3 — Decoded value of the 3rd element in the tuple.

static void DecodeKey<T1, T2, T3>(ReadOnlySpan<byte> packedKey, out T1 item1, out T2 item2, out T3 item3)

Unpack a key containing three elements

  • packedKey — Slice that should contain the packed representation of a tuple with three elements
  • item1 — Decoded value of the 1st element in the tuple.
  • item2 — Decoded value of the 2nd element in the tuple.
  • item3 — Decoded value of the 3rd element in the tuple.

static void DecodeKey<T1, T2, T3, T4>(Slice packedKey, out T1 item1, out T2 item2, out T3 item3, out T4 item4)

Unpack a key containing four elements

  • packedKey — Slice that should contain the packed representation of a tuple with four elements
  • item1 — Decoded value of the 1st element in the tuple.
  • item2 — Decoded value of the 2nd element in the tuple.
  • item3 — Decoded value of the 3rd element in the tuple.
  • item4 — Decoded value of the 4th element in the tuple.

static void DecodeKey<T1, T2, T3, T4>(ReadOnlySpan<byte> packedKey, out T1 item1, out T2 item2, out T3 item3, out T4 item4)

Unpack a key containing four elements

  • packedKey — Slice that should contain the packed representation of a tuple with four elements
  • item1 — Decoded value of the 1st element in the tuple.
  • item2 — Decoded value of the 2nd element in the tuple.
  • item3 — Decoded value of the 3rd element in the tuple.
  • item4 — Decoded value of the 4th element in the tuple.

static void DecodeKey<T1, T2, T3, T4, T5>(Slice packedKey, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5)

Unpack a key containing five elements

  • packedKey — Slice that should contain the packed representation of a tuple with five elements
  • item1 — Decoded value of the 1st element in the tuple.
  • item2 — Decoded value of the 2nd element in the tuple.
  • item3 — Decoded value of the 3rd element in the tuple.
  • item4 — Decoded value of the 4th element in the tuple.
  • item5 — Decoded value of the 5th element in the tuple.

static void DecodeKey<T1, T2, T3, T4, T5>(ReadOnlySpan<byte> packedKey, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5)

Unpack a key containing five elements

  • packedKey — Slice that should contain the packed representation of a tuple with five elements
  • item1 — Decoded value of the 1st element in the tuple.
  • item2 — Decoded value of the 2nd element in the tuple.
  • item3 — Decoded value of the 3rd element in the tuple.
  • item4 — Decoded value of the 4th element in the tuple.
  • item5 — Decoded value of the 5th element in the tuple.

static void DecodeKey<T1, T2, T3, T4, T5, T6>(Slice packedKey, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6)

Unpack a key containing six elements

  • packedKey — Slice that should contain the packed representation of a tuple with six elements
  • item1 — Decoded value of the 1st element in the tuple.
  • item2 — Decoded value of the 2nd element in the tuple.
  • item3 — Decoded value of the 3rd element in the tuple.
  • item4 — Decoded value of the 4th element in the tuple.
  • item5 — Decoded value of the 5th element in the tuple.
  • item6 — Decoded value of the 6th element in the tuple.

static void DecodeKey<T1, T2, T3, T4, T5, T6>(ReadOnlySpan<byte> packedKey, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6)

Unpack a key containing six elements

  • packedKey — Slice that should contain the packed representation of a tuple with six elements
  • item1 — Decoded value of the 1st element in the tuple.
  • item2 — Decoded value of the 2nd element in the tuple.
  • item3 — Decoded value of the 3rd element in the tuple.
  • item4 — Decoded value of the 4th element in the tuple.
  • item5 — Decoded value of the 5th element in the tuple.
  • item6 — Decoded value of the 6th element in the tuple.

static void DecodeKey<T1, T2, T3, T4, T5, T6, T7>(Slice packedKey, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7)

Unpack a key containing seven elements

  • packedKey — Slice that should contain the packed representation of a tuple with seven elements
  • item1 — Decoded value of the 1st element in the tuple.
  • item2 — Decoded value of the 2nd element in the tuple.
  • item3 — Decoded value of the 3rd element in the tuple.
  • item4 — Decoded value of the 4th element in the tuple.
  • item5 — Decoded value of the 5th element in the tuple.
  • item6 — Decoded value of the 6th element in the tuple.
  • item7 — Decoded value of the 7th element in the tuple.

static void DecodeKey<T1, T2, T3, T4, T5, T6, T7>(ReadOnlySpan<byte> packedKey, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7)

Unpack a key containing seven elements

  • packedKey — Slice that should contain the packed representation of a tuple with seven elements
  • item1 — Decoded value of the 1st element in the tuple.
  • item2 — Decoded value of the 2nd element in the tuple.
  • item3 — Decoded value of the 3rd element in the tuple.
  • item4 — Decoded value of the 4th element in the tuple.
  • item5 — Decoded value of the 5th element in the tuple.
  • item6 — Decoded value of the 6th element in the tuple.
  • item7 — Decoded value of the 7th element in the tuple.

static void DecodeKey<T1, T2, T3, T4, T5, T6, T7, T8>(Slice packedKey, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8)

Unpack a key containing eight elements

  • packedKey — Slice that should contain the packed representation of a tuple with eight elements
  • item1 — Decoded value of the 1st element in the tuple.
  • item2 — Decoded value of the 2nd element in the tuple.
  • item3 — Decoded value of the 3rd element in the tuple.
  • item4 — Decoded value of the 4th element in the tuple.
  • item5 — Decoded value of the 5th element in the tuple.
  • item6 — Decoded value of the 6th element in the tuple.
  • item7 — Decoded value of the 7th element in the tuple.
  • item8 — Decoded value of the 8th element in the tuple.

static void DecodeKey<T1, T2, T3, T4, T5, T6, T7, T8>(ReadOnlySpan<byte> packedKey, out T1 item1, out T2 item2, out T3 item3, out T4 item4, out T5 item5, out T6 item6, out T7 item7, out T8 item8)

Unpack a key containing eight elements

  • packedKey — Slice that should contain the packed representation of a tuple with eight elements
  • item1 — Decoded value of the 1st element in the tuple.
  • item2 — Decoded value of the 2nd element in the tuple.
  • item3 — Decoded value of the 3rd element in the tuple.
  • item4 — Decoded value of the 4th element in the tuple.
  • item5 — Decoded value of the 5th element in the tuple.
  • item6 — Decoded value of the 6th element in the tuple.
  • item7 — Decoded value of the 7th element in the tuple.
  • item8 — Decoded value of the 8th element in the tuple.

static void DecodeKey<T1, T2, T3, T4, T5, T6, T7, T8, T9>(Slice packedKey, 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)

Unpack a key containing eight elements

  • packedKey — Slice that should contain the packed representation of a tuple with eight elements
  • item1 — Decoded value of the 1st element in the tuple.
  • item2 — Decoded value of the 2nd element in the tuple.
  • item3 — Decoded value of the 3rd element in the tuple.
  • item4 — Decoded value of the 4th element in the tuple.
  • item5 — Decoded value of the 5th element in the tuple.
  • item6 — Decoded value of the 6th element in the tuple.
  • item7 — Decoded value of the 7th element in the tuple.
  • item8 — Decoded value of the 8th element in the tuple.
  • item9 — Decoded value of the 9th element in the tuple.

static void DecodeKey<T1, T2, T3, T4, T5, T6, T7, T8, T9>(ReadOnlySpan<byte> packedKey, 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)

Unpack a key containing eight elements

  • packedKey — Slice that should contain the packed representation of a tuple with eight elements
  • item1 — Decoded value of the 1st element in the tuple.
  • item2 — Decoded value of the 2nd element in the tuple.
  • item3 — Decoded value of the 3rd element in the tuple.
  • item4 — Decoded value of the 4th element in the tuple.
  • item5 — Decoded value of the 5th element in the tuple.
  • item6 — Decoded value of the 6th element in the tuple.
  • item7 — Decoded value of the 7th element in the tuple.
  • item8 — Decoded value of the 8th element in the tuple.
  • item9 — Decoded value of the 9th element in the tuple.

DecodeKeyAt

static T1 DecodeKeyAt<T1>(Slice packedKey, int index)

Unpack the value of the element at the given position in a tuple

  • packedKey — Slice that should contain the packed representation of a tuple
  • index — Index of the item to decode, from the start of the tuple

Returns: Decoded value of the item at this position in the tuple. Throws an exception if the tuple is empty, or does not have enough elements.

static T1 DecodeKeyAt<T1>(ReadOnlySpan<byte> packedKey, int index)

Unpack the value of the element at the given position in a tuple

  • packedKey — Slice that should contain the packed representation of a tuple
  • index — Index of the item to decode, from the start of the tuple

Returns: Decoded value of the item at this position in the tuple. Throws an exception if the tuple is empty, or does not have enough elements.

DecodeLast

static T1 DecodeLast<T1>(Slice packedKey, int? expectedSize = null)

Unpack a tuple and only return its last element

  • packedKey — Slice that should be entirely parsable as a tuple of at least one element
  • expectedSize — If not null, verifies that the tuple has the expected size

Returns: Decoded value of the last item in the tuple

static T1 DecodeLast<T1>(ReadOnlySpan<byte> packedKey, int? expectedSize = null)

Unpack a tuple and only return its last element

  • packedKey — Slice that should be entirely parsable as a tuple of at least one element
  • expectedSize — If not null, verifies that the tuple has the expected size

Returns: Decoded value of the last item in the tuple

static (T1, T2) DecodeLast<T1, T2>(Slice packedKey, int? expectedSize = null)

Unpack a tuple and only return its last 2 elements

  • packedKey — Slice that should be entirely parsable as a tuple of at least 2 elements
  • expectedSize — If not null, verifies that the tuple has the expected size

Returns: Decoded values of the last two elements in the tuple

static (T1, T2) DecodeLast<T1, T2>(ReadOnlySpan<byte> packedKey, int? expectedSize = null)

Unpack a tuple and only return its last 2 elements

  • packedKey — Slice that should be entirely parsable as a tuple of at least 2 elements
  • expectedSize — If not null, 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>(Slice packedKey, int? expectedSize = null)

Unpack a tuple and only return its last 3 elements

  • packedKey — Slice that should be entirely parsable as a tuple of at least 3 elements
  • expectedSize — If not null, verifies that the tuple has the expected size

Returns: Decoded values of the last three elements in the tuple

static (T1, T2, T3) DecodeLast<T1, T2, T3>(ReadOnlySpan<byte> packedKey, int? expectedSize = null)

Unpack a tuple and only return its last 3 elements

  • packedKey — Slice that should be entirely parsable as a tuple of at least 3 elements
  • expectedSize — If not null, 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>(Slice packedKey, int? expectedSize = null)

Unpack a tuple and only return its last 4 elements

  • packedKey — Slice that should be entirely parsable as a tuple of at least 4 elements
  • expectedSize — If not null, verifies that the tuple has the expected size

Returns: Decoded values of the last four elements in the tuple

static (T1, T2, T3, T4) DecodeLast<T1, T2, T3, T4>(ReadOnlySpan<byte> packedKey, int? expectedSize = null)

Unpack a tuple and only return its last 4 elements

  • packedKey — Slice that should be entirely parsable as a tuple of at least 4 elements
  • expectedSize — If not null, verifies that the tuple has the expected size

Returns: Decoded values of the last four elements in the tuple

EncodeKey

static Slice EncodeKey<T1>(T1 item1)

Pack a 1-tuple directly into a slice

static Slice EncodeKey<T1, T2>(T1 item1, T2 item2)

Pack a 2-tuple directly into a slice

static Slice EncodeKey<T1, T2, T3>(T1 item1, T2 item2, T3 item3)

Pack a 3-tuple directly into a slice

static Slice EncodeKey<T1, T2, T3, T4>(T1 item1, T2 item2, T3 item3, T4 item4)

Pack a 4-tuple directly into a slice

static Slice EncodeKey<T1, T2, T3, T4, T5>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5)

Pack a 5-tuple directly into a slice

static Slice EncodeKey<T1, T2, T3, T4, T5, T6>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6)

Pack a 6-tuple directly into a slice

static Slice EncodeKey<T1, T2, T3, T4, T5, T6, T7>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7)

Pack a 7-tuple directly into a slice

static Slice EncodeKey<T1, T2, T3, T4, T5, T6, T7, T8>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, T8 item8)

Pack an 8-tuple directly into a slice

static Slice EncodeKey<T1, T2, T3, T4, T5, T6, T7, T8, T9>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, T8 item8, T9 item9)

Pack an 9-tuple directly into a slice

EncodePrefixedKey

static Slice EncodePrefixedKey<T1>(Slice prefix, T1 value)

Efficiently concatenate a prefix with the packed representation of a 1-tuple

static Slice EncodePrefixedKey<T1>(ReadOnlySpan<byte> prefix, T1 value)

Efficiently concatenate a prefix with the packed representation of a 1-tuple

static Slice EncodePrefixedKey<T1, T2>(Slice prefix, T1 value1, T2 value2)

Efficiently concatenate a prefix with the packed representation of a 2-tuple

static Slice EncodePrefixedKey<T1, T2>(ReadOnlySpan<byte> prefix, T1 value1, T2 value2)

Efficiently concatenate a prefix with the packed representation of a 2-tuple

static Slice EncodePrefixedKey<T1, T2, T3>(Slice prefix, T1 value1, T2 value2, T3 value3)

Efficiently concatenate a prefix with the packed representation of a 3-tuple

static Slice EncodePrefixedKey<T1, T2, T3>(ReadOnlySpan<byte> prefix, T1 value1, T2 value2, T3 value3)

Efficiently concatenate a prefix with the packed representation of a 3-tuple

static Slice EncodePrefixedKey<T1, T2, T3, T4>(Slice prefix, T1 value1, T2 value2, T3 value3, T4 value4)

Efficiently concatenate a prefix with the packed representation of a 4-tuple

static Slice EncodePrefixedKey<T1, T2, T3, T4>(ReadOnlySpan<byte> prefix, T1 value1, T2 value2, T3 value3, T4 value4)

Efficiently concatenate a prefix with the packed representation of a 4-tuple

static Slice EncodePrefixedKey<T1, T2, T3, T4, T5>(Slice prefix, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5)

Efficiently concatenate a prefix with the packed representation of a 5-tuple

static Slice EncodePrefixedKey<T1, T2, T3, T4, T5>(ReadOnlySpan<byte> prefix, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5)

Efficiently concatenate a prefix with the packed representation of a 5-tuple

static Slice EncodePrefixedKey<T1, T2, T3, T4, T5, T6>(Slice prefix, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6)

Efficiently concatenate a prefix with the packed representation of a 6-tuple

static Slice EncodePrefixedKey<T1, T2, T3, T4, T5, T6>(ReadOnlySpan<byte> prefix, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6)

Efficiently concatenate a prefix with the packed representation of a 6-tuple

static Slice EncodePrefixedKey<T1, T2, T3, T4, T5, T6, T7>(Slice prefix, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7)

Efficiently concatenate a prefix with the packed representation of a 7-tuple

static Slice EncodePrefixedKey<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 concatenate a prefix with the packed representation of a 7-tuple

static Slice EncodePrefixedKey<T1, T2, T3, T4, T5, T6, T7, T8>(Slice prefix, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8)

Efficiently concatenate a prefix with the packed representation of an 8-tuple

static Slice EncodePrefixedKey<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 concatenate a prefix with the packed representation of an 8-tuple

Pack

static Slice Pack(IVarTuple tuple)

Pack a tuple into a slice

  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<TTuple>(in TTuple tuple)

Pack a tuple into a slice

  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1>(in (T1) tuple)

Pack a tuple into a slice

  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2>(in (T1, T2) tuple)

Pack a tuple into a slice

  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2, T3>(in (T1, T2, T3) tuple)

Pack a tuple into a slice

  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2, T3, T4>(in (T1, T2, T3, T4) tuple)

Pack a tuple into a slice

  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2, T3, T4, T5>(in (T1, T2, T3, T4, T5) tuple)

Pack a tuple into a slice

  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2, T3, T4, T5, T6>(in (T1, T2, T3, T4, T5, T6) tuple)

Pack a tuple into a slice

  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2, T3, T4, T5, T6, T7>(in (T1, T2, T3, T4, T5, T6, T7) tuple)

Pack a tuple into a slice

  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2, T3, T4, T5, T6, T7, T8>(in (T1, T2, T3, T4, T5, T6, T7, (T8)) tuple)

Pack a tuple into a slice

  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2, T3, T4, T5, T6, T7, T8, T9>(in (T1, T2, T3, T4, T5, T6, T7, (T8, T9)) tuple)

Pack a tuple into a slice

  • tuple — Tuple that must be serialized into a binary slice

static SliceOwner Pack<TTuple>(in TTuple tuple, ArrayPool<byte> pool)

Packs a tuple into a SliceOwner

  • tuple — Tuple that must be serialized into a binary slice
  • pool — Pool used to allocate the buffers

static Slice Pack<TTuple>(Slice prefix, TTuple tuple)

Efficiently concatenate a prefix with the packed representation of a tuple

  • prefix — Prefix added to the start of the packed slice
  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<TTuple>(ReadOnlySpan<byte> prefix, TTuple tuple)

Efficiently concatenate a prefix with the packed representation of a tuple

  • prefix — Prefix added to the start of the packed slice
  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1>(Slice prefix, STuple<T1> tuple)

Pack a tuple into a slice

  • prefix — Prefix added to the start of the packed slice
  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1>(ReadOnlySpan<byte> prefix, STuple<T1> tuple)

Pack a tuple into a slice

  • prefix — Prefix added to the start of the packed slice
  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2>(Slice prefix, STuple<T1, T2> tuple)

Pack a tuple into a slice

  • prefix — Prefix added to the start of the packed slice
  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2>(ReadOnlySpan<byte> prefix, STuple<T1, T2> tuple)

Pack a tuple into a slice

  • prefix — Prefix added to the start of the packed slice
  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2, T3>(Slice prefix, STuple<T1, T2, T3> tuple)

Pack a tuple into a slice

  • prefix — Prefix added to the start of the packed slice
  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2, T3>(ReadOnlySpan<byte> prefix, STuple<T1, T2, T3> tuple)

Pack a tuple into a slice

  • prefix — Prefix added to the start of the packed slice
  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2, T3, T4>(Slice prefix, STuple<T1, T2, T3, T4> tuple)

Pack a tuple into a slice

  • prefix — Prefix added to the start of the packed slice
  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2, T3, T4>(ReadOnlySpan<byte> prefix, STuple<T1, T2, T3, T4> tuple)

Pack a tuple into a slice

  • prefix — Prefix added to the start of the packed slice
  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2, T3, T4, T5>(Slice prefix, STuple<T1, T2, T3, T4, T5> tuple)

Pack a tuple into a slice

  • prefix — Prefix added to the start of the packed slice
  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2, T3, T4, T5>(ReadOnlySpan<byte> prefix, STuple<T1, T2, T3, T4, T5> tuple)

Pack a tuple into a slice

  • prefix — Prefix added to the start of the packed slice
  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2, T3, T4, T5, T6>(Slice prefix, STuple<T1, T2, T3, T4, T5, T6> tuple)

Pack a tuple into a slice

  • prefix — Common prefix added to all the tuples
  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2, T3, T4, T5, T6>(ReadOnlySpan<byte> prefix, STuple<T1, T2, T3, T4, T5, T6> tuple)

Pack a tuple into a slice

  • prefix — Common prefix added to all the tuples
  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2, T3, T4, T5, T6, T7>(Slice prefix, STuple<T1, T2, T3, T4, T5, T6, T7> tuple)

Pack a tuple into a slice

  • prefix — Common prefix added to all the tuples
  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2, T3, T4, T5, T6, T7>(ReadOnlySpan<byte> prefix, STuple<T1, T2, T3, T4, T5, T6, T7> tuple)

Pack a tuple into a slice

  • prefix — Common prefix added to all the tuples
  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2, T3, T4, T5, T6, T7, T8>(Slice prefix, STuple<T1, T2, T3, T4, T5, T6, T7, T8> tuple)

Pack a tuple into a slice

  • prefix — Common prefix added to all the tuples
  • tuple — Tuple that must be serialized into a binary slice

static Slice Pack<T1, T2, T3, T4, T5, T6, T7, T8>(ReadOnlySpan<byte> prefix, STuple<T1, T2, T3, T4, T5, T6, T7, T8> tuple)

Pack a tuple into a slice

  • prefix — Common prefix added to all the tuples
  • tuple — Tuple that must be serialized into a binary slice

PackTo

static void PackTo<TTuple>(ref SliceWriter writer, TTuple tuple)

Efficiently write the packed representation of a tuple

  • writer — Output buffer
  • tuple — Tuple that must be serialized into a binary slice

static void PackTo<TTuple>(TupleWriter writer, TTuple tuple)

Efficiently write the packed representation of a tuple

  • writer — Output buffer
  • tuple — Tuple that must be serialized into a binary slice

PackTuples

static Slice[] PackTuples(params IVarTuple[] tuples)

Pack 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[] PackTuples(ReadOnlySpan<IVarTuple> tuples)

Pack 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[] PackTuples<TTuple>(params TTuple[] tuples)

Pack 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[] PackTuples<TTuple>(ReadOnlySpan<TTuple> tuples)

Pack 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[] PackTuples(IEnumerable<IVarTuple> tuples)

Pack a sequence 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[] PackTuples(Slice prefix, params IVarTuple[] tuples)

Pack an array of N-tuples, all sharing the same buffer

  • prefix — Common prefix added to all the tuples
  • tuples — 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[] PackTuples(ReadOnlySpan<byte> prefix, params IVarTuple[] tuples)

Pack an array of N-tuples, all sharing the same buffer

  • prefix — Common prefix added to all the tuples
  • tuples — 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[] PackTuples(Slice prefix, ReadOnlySpan<IVarTuple> tuples)

Pack an array of N-tuples, all sharing the same buffer

  • prefix — Common prefix added to all the tuples
  • tuples — 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[] PackTuples(ReadOnlySpan<byte> prefix, ReadOnlySpan<IVarTuple> tuples)

Pack an array of N-tuples, all sharing the same buffer

  • prefix — Common prefix added to all the tuples
  • tuples — 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[] PackTuples(Slice prefix, IEnumerable<IVarTuple> tuples)

Pack a sequence of N-tuples, all sharing the same buffer

  • prefix — Common prefix added to all the tuples
  • tuples — 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[] PackTuples(ReadOnlySpan<byte> prefix, IEnumerable<IVarTuple> tuples)

Pack a sequence of N-tuples, all sharing the same buffer

  • prefix — Common prefix added to all the tuples
  • tuples — 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[] PackTuples<TElement, TTuple>(Slice prefix, TElement[] elements, Func<TElement, TTuple> transform)

static Slice[] PackTuples<TElement, TTuple>(ReadOnlySpan<byte> prefix, TElement[] elements, Func<TElement, TTuple> transform)

static Slice[] PackTuples<TElement, TTuple>(Slice prefix, IEnumerable<TElement> elements, Func<TElement, TTuple> transform)

static Slice[] PackTuples<TElement, TTuple>(ReadOnlySpan<byte> prefix, IEnumerable<TElement> elements, Func<TElement, TTuple> transform)

TryCountItems

static bool TryCountItems(ReadOnlySpan<byte> packedKey, out int count)

Counts the number of items in a packed tuple, without decoding them

  • packedKey — Binary key containing a previously packed tuple
  • count — Number of items in the tuple, or 0 if the bytes are not a valid tuple

Returns: false if the bytes are not a valid tuple

TryDecodeFirst

static bool TryDecodeFirst<T1>(Slice packedKey, out T1 item1)

Unpack a tuple and only return the last element

  • packedKey — Slice that should be entirely parsable as a tuple of at least 2 elements
  • item1 — Last decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeFirst<T1>(ReadOnlySpan<byte> packedKey, out T1 item1)

Unpack a tuple and only return the last element

  • packedKey — Slice that should be entirely parsable as a tuple of at least 2 elements
  • item1 — Last decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeFirst<T1>(Slice packedKey, int expectedSize, out T1 item1)

Unpack a tuple and only return the last element

  • packedKey — Slice that should be entirely parsable as a tuple of at least 2 elements
  • expectedSize — Expected size of the decoded tuple
  • item1 — Last decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeFirst<T1>(ReadOnlySpan<byte> packedKey, int expectedSize, out T1 item1)

Unpack a tuple and only return the last element

  • packedKey — Slice that should be entirely parsable as a tuple of at least 2 elements
  • expectedSize — Expected size of the decoded tuple
  • item1 — Last decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeFirst<T1, T2>(Slice packedKey, 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 elements
  • item1 — First decoded element
  • item2 — Second decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeFirst<T1, T2>(ReadOnlySpan<byte> packedKey, 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 elements
  • item1 — First decoded element
  • item2 — Second decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeFirst<T1, T2>(Slice 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 elements
  • expectedSize — Expected size of the decoded tuple
  • item1 — First decoded element
  • item2 — Second decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

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 elements
  • expectedSize — Expected size of the decoded tuple
  • item1 — First decoded element
  • item2 — Second decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeFirst<T1, T2, T3>(Slice packedKey, 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 elements
  • item1 — First decoded element
  • item2 — Second decoded element
  • item3 — Third decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeFirst<T1, T2, T3>(ReadOnlySpan<byte> packedKey, 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 elements
  • item1 — First decoded element
  • item2 — Second decoded element
  • item3 — Third decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeFirst<T1, T2, T3>(Slice 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 elements
  • expectedSize — Expected size of the decoded tuple
  • item1 — First decoded element
  • item2 — Second decoded element
  • item3 — Third decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

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 elements
  • expectedSize — Expected size of the decoded tuple
  • item1 — First decoded element
  • item2 — Second decoded element
  • item3 — Third decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeFirst<T1, T2, T3, T4>(Slice packedKey, 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 elements
  • item1 — First decoded element
  • item2 — Second decoded element
  • item3 — Third decoded element
  • item4 — Fourth decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeFirst<T1, T2, T3, T4>(ReadOnlySpan<byte> packedKey, 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 elements
  • item1 — First decoded element
  • item2 — Second decoded element
  • item3 — Third decoded element
  • item4 — Fourth decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeFirst<T1, T2, T3, T4>(Slice 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 elements
  • expectedSize — Expected size of the decoded tuple
  • item1 — First decoded element
  • item2 — Second decoded element
  • item3 — Third decoded element
  • item4 — Fourth decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

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 elements
  • expectedSize — Expected size of the decoded tuple
  • item1 — First decoded element
  • item2 — Second decoded element
  • item3 — Third decoded element
  • item4 — Fourth decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

TryDecodeKey

static bool TryDecodeKey<T1>(Slice packedKey, out T1 item1)

Unpack the value of a singleton tuple

  • packedKey — Slice that should contain the packed representation of a tuple with a single element
  • item1 — Decoded value of the only item in the tuple. Throws an exception if the tuple is empty, or has more than one element.

Returns: true if the packed key was successfully unpacked.

static bool TryDecodeKey<T1>(ReadOnlySpan<byte> packedKey, out T1 item1)

Unpack the value of a singleton tuple

  • packedKey — Slice that should contain the packed representation of a tuple with a single element
  • item1 — Decoded value of the only item in the tuple. Throws an exception if the tuple is empty, or has more than one element.

Returns: true if the packed key was successfully unpacked.

TryDecodeKeyAt

static bool TryDecodeKeyAt<T1>(Slice packedKey, int index, out T1 item1)

Unpack the value of the element at the given position in a tuple

  • packedKey — Slice that should contain the packed representation of a tuple
  • index — Index of the item to decode, from the start of the tuple
  • item1 — Receives the decoded value, if successful

Returns: true if the packed key was successfully unpacked.

static bool TryDecodeKeyAt<T1>(ReadOnlySpan<byte> packedKey, int index, out T1 item1)

Unpack the value of the element at the given position in a tuple

  • packedKey — Slice that should contain the packed representation of a tuple
  • index — Index of the item to decode, from the start of the tuple
  • item1 — Receives the decoded value, if successful

Returns: true if the packed key was successfully unpacked.

TryDecodeLast

static bool TryDecodeLast<T1>(Slice packedKey, out T1 item1)

Unpack a tuple and only return the last element

  • packedKey — Slice that should be entirely parsable as a tuple of at least 2 elements
  • item1 — Last decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeLast<T1>(ReadOnlySpan<byte> packedKey, out T1 item1)

Unpack a tuple and only return the last element

  • packedKey — Slice that should be entirely parsable as a tuple of at least 2 elements
  • item1 — Last decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeLast<T1>(Slice packedKey, int expectedSize, out T1 item1)

Unpack a tuple and only return the last element

  • packedKey — Slice that should be entirely parsable as a tuple of at least 2 elements
  • expectedSize — Expected size of the decoded tuple
  • item1 — Last decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeLast<T1>(ReadOnlySpan<byte> packedKey, int expectedSize, out T1 item1)

Unpack a tuple and only return the last element

  • packedKey — Slice that should be entirely parsable as a tuple of at least 2 elements
  • expectedSize — Expected size of the decoded tuple
  • item1 — Last decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeLast<T1, T2>(Slice packedKey, 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 elements
  • item1 — First decoded element
  • item2 — Second decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeLast<T1, T2>(ReadOnlySpan<byte> packedKey, 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 elements
  • item1 — First decoded element
  • item2 — Second decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeLast<T1, T2>(Slice 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 elements
  • expectedSize — Expected size of the decoded tuple
  • item1 — First decoded element
  • item2 — Second decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

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 elements
  • expectedSize — Expected size of the decoded tuple
  • item1 — First decoded element
  • item2 — Second decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeLast<T1, T2, T3>(Slice packedKey, 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 elements
  • item1 — First decoded element
  • item2 — Second decoded element
  • item3 — Third decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeLast<T1, T2, T3>(ReadOnlySpan<byte> packedKey, 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 elements
  • item1 — First decoded element
  • item2 — Second decoded element
  • item3 — Third decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeLast<T1, T2, T3>(Slice 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 elements
  • expectedSize — Expected size of the decoded tuple
  • item1 — First decoded element
  • item2 — Second decoded element
  • item3 — Third decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

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 elements
  • expectedSize — Expected size of the decoded tuple
  • item1 — First decoded element
  • item2 — Second decoded element
  • item3 — Third decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeLast<T1, T2, T3, T4>(Slice packedKey, 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 elements
  • item1 — First decoded element
  • item2 — Second decoded element
  • item3 — Third decoded element
  • item4 — Fourth decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeLast<T1, T2, T3, T4>(ReadOnlySpan<byte> packedKey, 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 elements
  • item1 — First decoded element
  • item2 — Second decoded element
  • item3 — Third decoded element
  • item4 — Fourth decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

static bool TryDecodeLast<T1, T2, T3, T4>(Slice 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 elements
  • expectedSize — Expected size of the decoded tuple
  • item1 — First decoded element
  • item2 — Second decoded element
  • item3 — Third decoded element
  • item4 — Fourth decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

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 elements
  • expectedSize — Expected size of the decoded tuple
  • item1 — First decoded element
  • item2 — Second decoded element
  • item3 — Third decoded element
  • item4 — Fourth decoded element

Returns: true if the tuple was decoded successfully, or false if the tuple is too small, or if there was an error while decoding

TryEncodeKey

static bool TryEncodeKey<T1>(Span<byte> destination, out int bytesWritten, T1 item1)

Pack a 1-tuple directly into a slice

static bool TryEncodeKey<T1, T2>(Span<byte> destination, out int bytesWritten, T1 item1, T2 item2)

Pack a 2-tuple directly into a slice

static bool TryEncodeKey<T1, T2, T3>(Span<byte> destination, out int bytesWritten, T1 item1, T2 item2, T3 item3)

Pack a 3-tuple directly into a slice

static bool TryEncodeKey<T1, T2, T3, T4>(Span<byte> destination, out int bytesWritten, T1 item1, T2 item2, T3 item3, T4 item4)

Pack a 4-tuple directly into a slice

static bool TryEncodeKey<T1, T2, T3, T4, T5>(Span<byte> destination, out int bytesWritten, T1 item1, T2 item2, T3 item3, T4 item4, T5 item5)

Pack a 5-tuple directly into a slice

static bool TryEncodeKey<T1, T2, T3, T4, T5, T6>(Span<byte> destination, out int bytesWritten, T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6)

Pack a 6-tuple directly into a slice

static bool TryEncodeKey<T1, T2, T3, T4, T5, T6, T7>(Span<byte> destination, out int bytesWritten, T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7)

Pack a 7-tuple directly into a slice

static bool TryEncodeKey<T1, T2, T3, T4, T5, T6, T7, T8>(Span<byte> destination, out int bytesWritten, T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, T8 item8)

Pack an 8-tuple directly into a slice

static bool TryEncodeKey<T1, T2, T3, T4, T5, T6, T7, T8, T9>(Span<byte> destination, out int bytesWritten, T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, T8 item8, T9 item9)

Pack a 9-tuple directly into a slice

TryPackTo

static bool TryPackTo<TTuple>(ref TupleSpanWriter writer, in TTuple tuple)

Pack a tuple into a slice

static bool TryPackTo<TTuple>(Span<byte> destination, out int bytesWritten, in TTuple tuple)

Pack a tuple into a slice

static bool TryPackTo<T1>(Span<byte> destination, out int bytesWritten, in (T1) tuple)

Packs a tuple into a destination buffer

  • destination — Destination buffer
  • bytesWritten — Number of bytes written to the buffer
  • tuple — Tuple that must be serialized into a binary slice

true if the operation was successful and the buffer large enough, or false if it was too small.

static bool TryPackTo<T1, T2>(Span<byte> destination, out int bytesWritten, in (T1, T2) tuple)

Packs a tuple into a destination buffer

  • destination — Destination buffer
  • bytesWritten — Number of bytes written to the buffer
  • tuple — Tuple that must be serialized into a binary slice

true if the operation was successful and the buffer large enough, or false if it was too small.

static bool TryPackTo<T1, T2, T3>(Span<byte> destination, out int bytesWritten, in (T1, T2, T3) tuple)

Packs a tuple into a destination buffer

  • destination — Destination buffer
  • bytesWritten — Number of bytes written to the buffer
  • tuple — Tuple that must be serialized into a binary slice

true if the operation was successful and the buffer large enough, or false if it was too small.

static bool TryPackTo<T1, T2, T3, T4>(Span<byte> destination, out int bytesWritten, in (T1, T2, T3, T4) tuple)

Packs a tuple into a destination buffer

  • destination — Destination buffer
  • bytesWritten — Number of bytes written to the buffer
  • tuple — Tuple that must be serialized into a binary slice

true if the operation was successful and the buffer large enough, or false if it was too small.

static bool TryPackTo<T1, T2, T3, T4, T5>(Span<byte> destination, out int bytesWritten, in (T1, T2, T3, T4, T5) tuple)

Packs a tuple into a destination buffer

  • destination — Destination buffer
  • bytesWritten — Number of bytes written to the buffer
  • tuple — Tuple that must be serialized into a binary slice

true if the operation was successful and the buffer large enough, or false if it was too small.

static bool TryPackTo<T1, T2, T3, T4, T5, T6>(Span<byte> destination, out int bytesWritten, in (T1, T2, T3, T4, T5, T6) tuple)

Packs a tuple into a destination buffer

  • destination — Destination buffer
  • bytesWritten — Number of bytes written to the buffer
  • tuple — Tuple that must be serialized into a binary slice

true if the operation was successful and the buffer large enough, or false if it was too small.

static bool TryPackTo<T1, T2, T3, T4, T5, T6, T7>(Span<byte> destination, out int bytesWritten, in (T1, T2, T3, T4, T5, T6, T7) tuple)

Packs a tuple into a destination buffer

  • destination — Destination buffer
  • bytesWritten — Number of bytes written to the buffer
  • tuple — Tuple that must be serialized into a binary slice

true if the operation was successful and the buffer large enough, or false if it was too small.

static bool TryPackTo<T1, T2, T3, T4, T5, T6, T7, T8>(Span<byte> destination, out int bytesWritten, in (T1, T2, T3, T4, T5, T6, T7, (T8)) tuple)

Packs a tuple into a destination buffer

  • destination — Destination buffer
  • bytesWritten — Number of bytes written to the buffer
  • tuple — Tuple that must be serialized into a binary slice

true if the operation was successful and the buffer large enough, or false if it was too small.

static bool TryPackTo<T1, T2, T3, T4, T5, T6, T7, T8, T9>(Span<byte> destination, out int bytesWritten, in (T1, T2, T3, T4, T5, T6, T7, (T8, T9)) tuple)

Packs a tuple into a destination buffer

  • destination — Destination buffer
  • bytesWritten — Number of bytes written to the buffer
  • tuple — Tuple that must be serialized into a binary slice

true if the operation was successful and the buffer large enough, or false if it was too small.

TryUnpack

static bool TryUnpack(Slice packedKey, out IVarTuple tuple)

Unpack a tuple from a serialized key blob

  • packedKey — Binary key containing a previously packed tuple
  • tuple — Unpacked tuple, or the empty tuple if the key is Empty

static bool TryUnpack(ReadOnlySpan<byte> packedKey, out SpanTuple tuple)

Unpack a tuple from a serialized key blob

  • packedKey — Binary key containing a previously packed tuple
  • tuple — Unpacked tuple, or the empty tuple if the key is Empty

static bool TryUnpack(ReadOnlySpan<byte> packedKey, Span<Range> buffer, out SpanTuple tuple)

Unpack a tuple from a serialized key blob, using a caller-supplied buffer for the element ranges

  • packedKey — Binary key containing a previously packed tuple
  • buffer — Receives the range of each element, typically stackalloc Range[8]. The returned tuple reads from this buffer, so it must stay valid and untouched while the tuple is used.
  • tuple — Unpacked tuple, or the empty tuple if the key is Empty

Returns: false when the buffer is too small or the bytes are not a valid tuple; use CountItems to size a buffer

Unpack

static IVarTuple Unpack(Slice packedKey)

Unpack a tuple from a serialized key blob

  • packedKey — Binary key containing a previously packed tuple

Returns: Unpacked tuple, or the empty tuple if the key is Empty

static SpanTuple Unpack(ReadOnlySpan<byte> packedKey)

Unpack a tuple from a serialized key blob

  • packedKey — Binary key containing a previously packed tuple

Returns: Unpacked tuple, or the empty tuple if the key is Empty

static SpanTuple Unpack(ReadOnlySpan<byte> packedKey, Span<Range> buffer)

Unpack a tuple from a serialized key blob, using a caller-supplied buffer for the element ranges

  • packedKey — Binary key containing a previously packed tuple
  • buffer — Receives the range of each element, typically stackalloc Range[8]. The returned tuple reads from this buffer, so it must stay valid and untouched while the tuple is used.

Returns: Unpacked tuple, or the empty tuple if packedKey is empty

UnpackOrDefault

static IVarTuple UnpackOrDefault(Slice packedKey)

Unpack a tuple from a binary representation

  • packedKey — Binary key containing a previously packed tuple, or Slice.Nil

Returns: Unpacked tuple, the empty tuple if packedKey is equal to Empty, or null if the key is Nil