Expand description
This module provides encoding of typed messages
Without the std feature enabled, you’ll only be able to encode to a core::fmt::Write source (e.g. a String)
If you enable the std feature, then you’ll also be able to encode to a std::io::Write source (e.g. a Vec<u8> or a std::net::TcpStream)
§Provided traits:
| Trait | Description | Feature | Example |
|---|---|---|---|
Format | Format this message to the core::fmt::Write | – | ping("asdf").format(&mut buf) |
Formattable | Using core::fmt::Write format this message | – | buf.format_msg(ping("asdf")) |
Encode | Encode this message to the std::io::Write | std | ping("asdf").encode(&mut buf) |
Encodable | Using std::io::Write type encode this message | std | buf.encode_msg(ping("asdf")) |
Using one of the functions creates one of the types.
These don’t allocate directly and when using with &'static str can be stored in static/const contexts.
§Example
use twitch_message::encode::{privmsg, Privmsg, Format, Formattable};
const KAPPA: Privmsg<'static> = privmsg("museun", "Kappa");
let vohiyo = privmsg("museun", "VoHiYo");
let mut buf = String::new();
KAPPA.format(&mut buf)?;
buf.format_msg(vohiyo)?;
assert_eq!(buf, "PRIVMSG #museun :Kappa\r\nPRIVMSG #museun :VoHiYo\r\n");Structs§
- Join
- The type produced by
join - Part
- The type produced by
part - Ping
- The type produced by
ping - Pong
- The type produced by
pong - Privmsg
- The type produced by
privmsgorreply - Raw
- The type produced by
raw - Register
- The type produced by
register
Enums§
- Capability
- Request a capability from Twitch
Constants§
- ALL_
CAPABILITIES - All of the
Capabilities
Traits§
- Encodable
std - A trait for encoding a message with
std::io::Write - Encode
std - A trait to encode a type onto this
std::io::Write - Format
- A trait to format a type onto this
core::fmt::Write - Formattable
- A trait for formatting a message with
core::fmt::Write
Functions§
- join
- Join a channel
- part
- Leave a channel
- ping
- Constructs a PING the server should reply to
- pong
- Construct a PONG message, these are used to respond to a Ping
- privmsg
- Sends a message to a channel
- raw
- Send a raw message to the server
- register
- This allows you to initialize the registration handshake with the server
- reply
- Sends a message to a channel, with a provided
reply-parent-msg-idattached