pub struct Client { /* private fields */ }
Expand description
Twitch IRC client.
This is the main interface for interacting with Twitch IRC.
This interface provides:
- Connection handshake
- Reconnect with backoff
- Receiving and sending messages
It is a low-level interface, which means it does not automatically handle:
- Rate limiting
- Same message bypass
- Reconnects / rejoining channels
- Latency measurement
Implementations§
source§impl Client
impl Client
sourcepub async fn recv(&mut self) -> Result<IrcMessage, RecvError>
pub async fn recv(&mut self) -> Result<IrcMessage, RecvError>
Read a single IrcMessage
from the underlying stream.
source§impl Client
impl Client
sourcepub async fn send_raw<'a, S>(&mut self, s: S) -> Result<(), SendError>
pub async fn send_raw<'a, S>(&mut self, s: S) -> Result<(), SendError>
Send a raw string through the TCP socket.
⚠ This call is not rate limited in any way.
⚠ The string MUST be terminated by \r\n
.
sourcepub fn privmsg<'a>(&'a mut self, channel: &'a str, text: &'a str) -> Privmsg<'a>
pub fn privmsg<'a>(&'a mut self, channel: &'a str, text: &'a str) -> Privmsg<'a>
Create a privmsg
from a channel
and text
.
client
.privmsg(msg.channel(), "yo")
.reply_to(msg.message_id())
.send()
.await?;
You can specify additional properties using the builder methods:
reply_to
: to specify areply-parent-msg-id
tag, which makes this privmsg a reply to another message.client_nonce
: to identify the message in theNotice
which Twitch may send as a response to this message.
sourcepub async fn ping(&mut self, nonce: &str) -> Result<(), SendError>
pub async fn ping(&mut self, nonce: &str) -> Result<(), SendError>
Send a PING
command with an optional nonce
argument.
sourcepub async fn pong(&mut self, ping: &Ping<'_>) -> Result<(), SendError>
pub async fn pong(&mut self, ping: &Ping<'_>) -> Result<(), SendError>
Send a PONG
command in response to a PING
.
source§impl Client
impl Client
sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
The ClientBuilder
provides a builder for setting up the client configuration.
sourcepub fn anonymous() -> impl Future<Output = Result<Client, ConnectError>>
pub fn anonymous() -> impl Future<Output = Result<Client, ConnectError>>
Attemps to connect anonymously.
sourcepub async fn reconnect(&mut self) -> Result<(), ReconnectError>
pub async fn reconnect(&mut self) -> Result<(), ReconnectError>
Attempt to reconnect to Twitch IRC.
source§impl Client
impl Client
pub fn config(&self) -> &Config
pub fn credentials(&self) -> &Credentials
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more