[][src]Trait brokaw::types::command::NntpCommand

pub trait NntpCommand: Display { }

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")

Implementors

impl NntpCommand for Article[src]

impl NntpCommand for AuthInfo[src]

impl NntpCommand for Body[src]

impl NntpCommand for Hdr[src]

impl NntpCommand for Head[src]

impl NntpCommand for List[src]

impl NntpCommand for Over[src]

impl NntpCommand for Stat[src]

impl NntpCommand for XOver[src]

impl NntpCommand for Capabilities[src]

impl NntpCommand for Group[src]

impl NntpCommand for ModeReader[src]

impl NntpCommand for Next[src]

impl NntpCommand for Quit[src]

impl NntpCommand for XFeatureCompress[src]

Loading content...