pub struct PrivmsgBuilder { /* private fields */ }
Expand description

A builder for constructing a Message or Privmsg (and its raw format)

use twitch_message::builders::PrivmsgBuilder;
use twitch_message::messages::{Privmsg, Message, MessageKind};

let builder = PrivmsgBuilder::default()
    .channel("museun")
    .sender("shaken_bot")
    .data("~ Kappa");

let expected = ":shaken_bot!shaken_bot@shaken_bot.tmi.twitch.tv PRIVMSG #museun :~ Kappa\r\n";

let msg: Message<'_> = builder.clone().finish_message()?;
assert_eq!(msg.raw, expected);
assert_eq!(msg.kind, MessageKind::Privmsg);

let pm: Privmsg<'_> = builder.finish_privmsg()?;
assert_eq!(pm.raw, expected);

Implementations§

Create a new builder

Give it some optional tags

Give it the required sender

Give it the required channel

Give it the required data

Construct a Privmsg from this builder

Construct a Message from this builder

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.