[−][src]Trait brokaw::types::command::NntpCommand
An NNTP command
All NntpCommands
must implement fmt::Display
such that
fmt
returns the string that should be sent over the wire.
Example: Implementing LISTGROUP
use std::fmt; use brokaw::types::command::NntpCommand; #[derive(Clone, Debug)] pub struct ListGroup { group: Option<String>, range: Option<(u32, u32)>, } impl fmt::Display for ListGroup { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "LISTGROUP")?; if let Some(group) = &self.group { write!(f, " {}", &group)?; } if let Some((low, high)) = &self.range { write!(f, " {}-{}", low, high)?; } Ok(()) } } impl NntpCommand for ListGroup {} let cmd = ListGroup { group: Some("misc.test".to_string()), range: Some((10, 20)) }; assert_eq!(cmd.to_string(), "LISTGROUP misc.test 10-20")