pub struct SelectorConfig {
pub config_number: u8,
pub call: String,
pub display: String,
pub tooltip: Option<String>,
pub reload: Option<Reload>,
pub group: Option<String>,
pub default_options: Vec<ConfigOptionValue>,
}
Expand description
A selector config UI element that allows the user to select an option from a drop-down list. The list of options should have default=true on exactly one item.
Typically, these configs are created in a lazy_static
, and passed to
ConfigStep::list_configs
.
§Example
use r_extcap::config::*;
let selector = SelectorConfig::builder()
.config_number(3)
.call("remote")
.display("Remote Channel")
.tooltip("Remote Channel Selector")
.default_options([
ConfigOptionValue::builder().value("if1").display("Remote1").default(true).build(),
ConfigOptionValue::builder().value("if2").display("Remote2").build(),
])
.build();
assert_eq!(
format!("{}", ExtcapFormatter(&selector)),
concat!(
"arg {number=3}{call=--remote}{display=Remote Channel}{tooltip=Remote Channel Selector}{type=selector}\n",
"value {arg=3}{value=if1}{display=Remote1}{default=true}\n",
"value {arg=3}{value=if2}{display=Remote2}{default=false}\n"
)
);
Fields§
§config_number: u8
The config number, a unique identifier for this config.
call: String
The command line option that will be sent to this extcap program. For
example, if this field is foobar
, and the corresponding value is 42
,
then --foobar 42
will be sent to this program during the extcap
capture.
display: String
The user-friendly label for the selector.
tooltip: Option<String>
The tooltip shown on when hovering over the UI element.
reload: Option<Reload>
If this is Some
, a refresh button will be shown next to the selector,
allowing the user to refresh the list of available options to the return
value of this function. The first element of the pair is the label of
the button, and the second element is the function that will be invoked
on click.
Note: In extcap, the key for the button label is called placeholder
,
for some reason.
group: Option<String>
The (user-visible) name of the tab which this config belongs to. If this
is None
, the config will be placed in a tab called “Default”.
default_options: Vec<ConfigOptionValue>
The default list of options presented by this selector.
Implementations§
Source§impl SelectorConfig
impl SelectorConfig
Sourcepub fn builder() -> SelectorConfigBuilder<((), (), (), (), (), (), ())>
pub fn builder() -> SelectorConfigBuilder<((), (), (), (), (), (), ())>
Create a builder for building SelectorConfig
.
On the builder, call .config_number(...)
, .call(...)
, .display(...)
, .tooltip(...)
(optional), .reload(...)
(optional), .group(...)
(optional), .default_options(...)
to set the values of the fields.
Finally, call .build()
to create the instance of SelectorConfig
.