pub struct StringConfig {
pub config_number: u8,
pub call: String,
pub display: String,
pub tooltip: Option<String>,
pub placeholder: Option<String>,
pub required: bool,
pub group: Option<String>,
pub validation: Option<String>,
pub save: bool,
}
Expand description
A field for entering a text value.
Typically, these configs are created in a lazy_static
, and passed to
ConfigStep::list_configs
.
§Example
use r_extcap::config::*;
let config = StringConfig::builder()
.config_number(1)
.call("server")
.display("IP Address")
.tooltip("IP Address for log server")
.validation(r"\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b")
.build();
assert_eq!(
format!("{}", ExtcapFormatter(&config)),
concat!(
r"arg {number=1}{call=--server}{display=IP Address}{tooltip=IP Address for log server}{validation=\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b}{type=string}",
"\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 text field.
tooltip: Option<String>
The tooltip shown on when hovering over the UI element.
placeholder: Option<String>
The placeholder string displayed if there is no value in the text field.
required: bool
Whether a value is required for this config.
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”.
validation: Option<String>
A regular expression string used to check the user input for validity.
Despite what the Wireshark documentation says, back-slashes in this
string do not need to be escaped. Just remember to use a Rust raw string
(e.g. r"\d\d\d\d"
).
save: bool
Whether to save the value of this config. If true, the value will be saved by Wireshark, and will be automatically populated next time that interface is selected by the user.
Note: This option is undocumented in the Wireshark documentation, but the functionality was added in https://gitlab.com/wireshark/wireshark/-/commit/97a1a50e200a6c50e0014dde7e8ec932c30190a1.
It does not behave correctly in some versions of Wireshark, with the same symptoms described in https://gitlab.com/wireshark/wireshark/-/issues/18487.
Implementations§
Source§impl StringConfig
impl StringConfig
Sourcepub fn builder() -> StringConfigBuilder<((), (), (), (), (), (), (), (), ())>
pub fn builder() -> StringConfigBuilder<((), (), (), (), (), (), (), (), ())>
Create a builder for building StringConfig
.
On the builder, call .config_number(...)
, .call(...)
, .display(...)
, .tooltip(...)
(optional), .placeholder(...)
(optional), .required(...)
(optional), .group(...)
(optional), .validation(...)
(optional), .save(...)
(optional) to set the values of the fields.
Finally, call .build()
to create the instance of StringConfig
.