pub trait PrintSentence {
// Required method
fn format_sentence(&self, f: &mut Formatter<'_>) -> Result;
// Provided method
fn print_sentence(&self) { ... }
}
Expand description
Elements that has a printable extcap sentence. See the documentation for
ExtcapFormatter
for details.
Required Methods§
Sourcefn format_sentence(&self, f: &mut Formatter<'_>) -> Result
fn format_sentence(&self, f: &mut Formatter<'_>) -> Result
The extcap interface expects certain output “sentences” to stdout to communicate with Wireshark, like
extcap {version=1.0}{help=Some help url}
This function writes to the formatter f
in that format.
Provided Methods§
Sourcefn print_sentence(&self)
fn print_sentence(&self)
Prints the extcap sentence to stdout.
Implementations on Foreign Types§
Source§impl PrintSentence for (&ConfigOptionValue, u8)
impl PrintSentence for (&ConfigOptionValue, u8)
fn format_sentence(&self, f: &mut Formatter<'_>) -> Result
Source§impl PrintSentence for (&MultiCheckValue, u8, Option<&MultiCheckValue>)
impl PrintSentence for (&MultiCheckValue, u8, Option<&MultiCheckValue>)
fn format_sentence(&self, f: &mut Formatter<'_>) -> Result
Implementors§
impl PrintSentence for BooleanConfig
impl PrintSentence for DoubleConfig
impl PrintSentence for FileSelectConfig
impl PrintSentence for IntegerConfig
impl PrintSentence for LongConfig
impl PrintSentence for MultiCheckConfig
impl PrintSentence for PasswordConfig
impl PrintSentence for RadioConfig
impl PrintSentence for SelectorConfig
impl PrintSentence for StringConfig
impl PrintSentence for TimestampConfig
impl PrintSentence for UnsignedConfig
impl PrintSentence for BooleanControl
impl PrintSentence for ButtonControl
impl PrintSentence for HelpButtonControl
impl PrintSentence for LoggerControl
impl PrintSentence for RestoreButtonControl
impl PrintSentence for SelectorControl
impl PrintSentence for StringControl
impl PrintSentence for Dlt
Print the configuration line suitable for use with --extcap-dlts
.
§Example
use r_extcap::config::ExtcapFormatter;
use r_extcap::interface::{DataLink, Dlt};
let dlt = Dlt {
data_link_type: DataLink::ETHERNET,
name: "ETHERNET".into(),
display: "IEEE 802.3 Ethernet".into(),
};
assert_eq!(
ExtcapFormatter(&dlt).to_string(),
"dlt {number=1}{name=ETHERNET}{display=IEEE 802.3 Ethernet}\n",
);
impl PrintSentence for Interface
use r_extcap::config::ExtcapFormatter;
use r_extcap::interface::{DataLink, Dlt, Interface};
assert_eq!(
ExtcapFormatter(&Interface{ value: "MyInterface".into(), display: "My interface".into(), dlt }).to_string(),
"interface {value=MyInterface}{display=My interface}\n",
);
impl PrintSentence for Metadata
§Example
use r_extcap::interface::Metadata;
let metadata = Metadata {
version: "3.2.1-test".into(),
help_url: "http://www.wireshark.org".into(),
display_description: "Just for testing".into(),
};
assert_eq!(
format!("{}", ExtcapFormatter(&metadata)),
"extcap {version=3.2.1-test}{help=http://www.wireshark.org}{display=Just for testing}\n"
)