Trait Command

Source
pub trait Command {
    const CMD_NAME: &'static [u8];

    // Required methods
    fn into_vec(self) -> Result<Bytes, CommandError>;
    fn try_parse(buf: &[u8]) -> Result<Self, CommandError>
       where Self: Sized;
}
Expand description

Trait used to implement a common interface for implementing new commands

Required Associated Constants§

Source

const CMD_NAME: &'static [u8]

Command name as a static byte slice

Required Methods§

Source

fn into_vec(self) -> Result<Bytes, CommandError>

Encodes the command into bytes

Source

fn try_parse(buf: &[u8]) -> Result<Self, CommandError>
where Self: Sized,

Tries to parse a buffer into a command

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Command for ConnectCommand

Source§

const CMD_NAME: &'static [u8] = b"CONNECT"

Source§

impl Command for Message

Source§

const CMD_NAME: &'static [u8] = b"MSG"

Source§

impl Command for PubCommand

Source§

const CMD_NAME: &'static [u8] = b"PUB"

Source§

impl Command for ServerInfo

Source§

const CMD_NAME: &'static [u8] = b"INFO"

Source§

impl Command for SubCommand

Source§

const CMD_NAME: &'static [u8] = b"SUB"

Source§

impl Command for UnsubCommand

Source§

const CMD_NAME: &'static [u8] = b"UNSUB"