FilterableValue

Trait FilterableValue 

Source
pub trait FilterableValue: Serialize + Private {
    type Column;
}
Expand description

Types which can appear as an argument to an index filtering operation for a column of type Column.

Types which can appear specifically as a terminating bound in a BTree index, which may be a range, instead use IndexScanRangeBoundsTerminator.

Because SpacetimeDB supports a only restricted set of types as index keys, only a small set of Column types have corresponding FilterableValue implementations. Specifically, these types are:

  • Signed and unsigned integers of various widths.
  • bool.
  • String, which is also filterable with &str.
  • Identity.
  • ConnectionId.
  • Hash.
  • No-payload enums annotated with #[derive(SpacetimeType)]. No-payload enums are sometimes called “plain,” “simple” or “C-style.” They are enums where no variant has any payload data.

Because SpacetimeDB indexes are present both on the server and in clients which use our various SDKs, implementing FilterableValue for a new column type is a significant burden, and is not as simple as adding a new impl FilterableValue block to our Rust code. To implement FilterableValue for a new column type, you must also:

  • Ensure (with automated tests) that the spacetimedb-codegen crate and accompanying SpacetimeDB client SDK can equality-compare and ordering-compare values of the column type, and that the resulting ordering is the same as the canonical ordering implemented by spacetimedb-sats for spacetimedb_sats::AlgebraicValue. This will nearly always require implementing bespoke comparison methods for the type in question, as most languages do not automatically make product types (structs or classes) sortable.
  • Extend our other supported module languages’ bindings libraries. so that they can also define tables with indexes keyed by the new filterable type.

Required Associated Types§

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl FilterableValue for &bool

Source§

impl FilterableValue for &i8

Source§

impl FilterableValue for &i16

Source§

impl FilterableValue for &i32

Source§

impl FilterableValue for &i64

Source§

impl FilterableValue for &i128

Source§

impl FilterableValue for &str

Source§

impl FilterableValue for &u8

Source§

impl FilterableValue for &u16

Source§

impl FilterableValue for &u32

Source§

impl FilterableValue for &u64

Source§

impl FilterableValue for &u128

Source§

impl FilterableValue for &String

Source§

impl FilterableValue for &i256

Source§

impl FilterableValue for &u256

Source§

impl FilterableValue for bool

Source§

impl FilterableValue for i8

Source§

impl FilterableValue for i16

Source§

impl FilterableValue for i32

Source§

impl FilterableValue for i64

Source§

impl FilterableValue for i128

Source§

impl FilterableValue for u8

Source§

impl FilterableValue for u16

Source§

impl FilterableValue for u32

Source§

impl FilterableValue for u64

Source§

impl FilterableValue for u128

Source§

impl FilterableValue for i256

Source§

impl FilterableValue for u256

Implementors§