pub trait Options {
// Required method
fn options() -> Vec<(String, String)>;
// Provided method
fn label_of(value: &str) -> String { ... }
}Expand description
A closed set of stored values, each with its label.
Derive it on a unit-variant enum with
#[derive(Options)]: each variant stores its
snake_case name and reads as its name in sentence case, and
#[option(value = "..", label = "..")] overrides either.
#[derive(Debug, Clone, Copy, PartialEq, Eq, tablo_core::Options)]
enum Status {
Draft,
#[option(label = "Live")]
Published,
}
Field::choice(Post::fields().status()).options(Status::options());
SelectFilter::new(Post::fields().status(), Status::options());
TextColumn::new(lens!(Post.status)).format(|status| Status::label_of(status));The derive also gives the enum value(), label() and from_value(), so
code that writes the column names a variant rather than a string.
Required Methods§
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".