Fixed documentation
This commit is contained in:
parent
32fb07646b
commit
8ed4820e0b
|
@ -8,7 +8,7 @@ license = "Unlicense"
|
||||||
name = "async-circe"
|
name = "async-circe"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://git.karx.xyz/circe/async-circe.git"
|
repository = "https://git.karx.xyz/circe/async-circe.git"
|
||||||
version = "0.2.2"
|
version = "0.2.3"
|
||||||
|
|
||||||
[dependencies.toml]
|
[dependencies.toml]
|
||||||
version = "0.5"
|
version = "0.5"
|
||||||
|
|
17
README.md
17
README.md
|
@ -11,21 +11,30 @@
|
||||||
To start using Circe, just add the crate to your `Cargo.toml`, and then follow the example below.
|
To start using Circe, just add the crate to your `Cargo.toml`, and then follow the example below.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use circe::{Client, Config, Command};
|
use async_circe::{commands::Command, Client, Config};
|
||||||
|
|
||||||
fn main() -> Result<(), std::io::Error> {
|
#[tokio::main(flavor = "current_thread")]
|
||||||
let config = Default::default();
|
async fn main() -> Result<(), tokio::io::Error> {
|
||||||
|
let config = Config::new(
|
||||||
|
&["#chaos", "#async-circe"],
|
||||||
|
"karx.xyz",
|
||||||
|
Some("+B"),
|
||||||
|
Some("async-circe"),
|
||||||
|
6697,
|
||||||
|
"circe",
|
||||||
|
);
|
||||||
let mut client = Client::new(config).await.unwrap();
|
let mut client = Client::new(config).await.unwrap();
|
||||||
client.identify().await.unwrap();
|
client.identify().await.unwrap();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if let Ok(ref command) = client.read().await {
|
if let Some(command) = client.read().await? {
|
||||||
if let Command::PRIVMSG(nick, channel, message) = command {
|
if let Command::PRIVMSG(nick, channel, message) = command {
|
||||||
println!("{} in {}: {}", nick, channel, message);
|
println!("{} in {}: {}", nick, channel, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Happy hacking!
|
Happy hacking!
|
||||||
|
|
2
examples/basic-config/Cargo.lock
generated
2
examples/basic-config/Cargo.lock
generated
|
@ -4,7 +4,7 @@ version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-circe"
|
name = "async-circe"
|
||||||
version = "0.2.0"
|
version = "0.2.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"native-tls",
|
"native-tls",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
|
|
@ -14,7 +14,7 @@ async fn main() -> Result<(), tokio::io::Error> {
|
||||||
client.identify().await.unwrap();
|
client.identify().await.unwrap();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if let Some(ref command) = client.read().await? {
|
if let Some(command) = client.read().await? {
|
||||||
if let Command::PRIVMSG(nick, channel, message) = command {
|
if let Command::PRIVMSG(nick, channel, message) = command {
|
||||||
println!("{} in {}: {}", nick, channel, message);
|
println!("{} in {}: {}", nick, channel, message);
|
||||||
}
|
}
|
||||||
|
|
2
examples/config-from-toml/Cargo.lock
generated
2
examples/config-from-toml/Cargo.lock
generated
|
@ -4,7 +4,7 @@ version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-circe"
|
name = "async-circe"
|
||||||
version = "0.2.0"
|
version = "0.2.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"native-tls",
|
"native-tls",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
@ -7,7 +7,7 @@ async fn main() -> Result<(), std::io::Error> {
|
||||||
client.identify().await.unwrap();
|
client.identify().await.unwrap();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if let Some(ref command) = client.read().await? {
|
if let Some(command) = client.read().await? {
|
||||||
if let Command::PRIVMSG(nick, channel, message) = command {
|
if let Command::PRIVMSG(nick, channel, message) = command {
|
||||||
println!("{} in {}: {}", nick, channel, message);
|
println!("{} in {}: {}", nick, channel, message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ use async_circe::{commands::Command, Client, Config};
|
||||||
#[tokio::main(flavor = "current_thread")]
|
#[tokio::main(flavor = "current_thread")]
|
||||||
async fn main() -> Result<(), tokio::io::Error> {
|
async fn main() -> Result<(), tokio::io::Error> {
|
||||||
// This tells tracing to show the debug log when the binary is run with
|
// This tells tracing to show the debug log when the binary is run with
|
||||||
// CIRCE_LOG="debug"
|
// CIRCE_LOG="tracing"
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
.with_env_filter(tracing_subscriber::EnvFilter::from_env("CIRCE_LOG"))
|
.with_env_filter(tracing_subscriber::EnvFilter::from_env("CIRCE_LOG"))
|
||||||
.init();
|
.init();
|
||||||
|
@ -20,7 +20,7 @@ async fn main() -> Result<(), tokio::io::Error> {
|
||||||
client.identify().await.unwrap();
|
client.identify().await.unwrap();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if let Some(ref command) = client.read().await? {
|
if let Some(command) = client.read().await? {
|
||||||
if let Command::PRIVMSG(nick, channel, message) = command {
|
if let Command::PRIVMSG(nick, channel, message) = command {
|
||||||
println!("{} in {}: {}", nick, channel, message);
|
println!("{} in {}: {}", nick, channel, message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,15 +17,12 @@ pub enum Command {
|
||||||
// SQUIT <server> <comment>
|
// SQUIT <server> <comment>
|
||||||
//
|
//
|
||||||
/// Request information about the admin of a given server.
|
/// Request information about the admin of a given server.
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.admin("libera.chat").await?;
|
/// client.admin("libera.chat").await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns IO errors from the TcpStream.
|
/// Returns IO errors from the TcpStream.
|
||||||
|
@ -34,15 +31,12 @@ pub enum Command {
|
||||||
String,
|
String,
|
||||||
),
|
),
|
||||||
/// Set the status of the client.
|
/// Set the status of the client.
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.away("afk").await?;
|
/// client.away("afk").await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
AWAY(
|
AWAY(
|
||||||
/// Message
|
/// Message
|
||||||
|
@ -51,15 +45,12 @@ pub enum Command {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
CAP(CapMode),
|
CAP(CapMode),
|
||||||
/// Invite someone to a channel.
|
/// Invite someone to a channel.
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.invite("liblemonirc", "#async_circe").await?;
|
/// client.invite("liblemonirc", "#async_circe").await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
INVITE(
|
INVITE(
|
||||||
/// User
|
/// User
|
||||||
|
@ -68,30 +59,24 @@ pub enum Command {
|
||||||
String,
|
String,
|
||||||
),
|
),
|
||||||
/// Join a channel.
|
/// Join a channel.
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.join("#main").await?;
|
/// client.join("#main").await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
JOIN(
|
JOIN(
|
||||||
/// Channel
|
/// Channel
|
||||||
String,
|
String,
|
||||||
),
|
),
|
||||||
/// List available channels on an IRC, or users in a channel.
|
/// List available channels on an IRC, or users in a channel.
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.list(None, None).await?;
|
/// client.list(None, None).await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
LIST(
|
LIST(
|
||||||
/// Channel
|
/// Channel
|
||||||
|
@ -100,15 +85,12 @@ pub enum Command {
|
||||||
Option<String>,
|
Option<String>,
|
||||||
),
|
),
|
||||||
/// Set the mode for a user.
|
/// Set the mode for a user.
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.mode("test", Some("+B")).await?;
|
/// client.mode("test", Some("+B")).await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
MODE(
|
MODE(
|
||||||
/// Channel
|
/// Channel
|
||||||
|
@ -117,15 +99,12 @@ pub enum Command {
|
||||||
Option<String>,
|
Option<String>,
|
||||||
),
|
),
|
||||||
/// Get all the people online in channels.
|
/// Get all the people online in channels.
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.names("#main,#async_circe", None).await?;
|
/// client.names("#main,#async_circe", None).await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
NAMES(
|
NAMES(
|
||||||
/// Channel
|
/// Channel
|
||||||
|
@ -134,30 +113,24 @@ pub enum Command {
|
||||||
Option<String>,
|
Option<String>,
|
||||||
),
|
),
|
||||||
/// Change your nickname on a server.
|
/// Change your nickname on a server.
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.nick("Not async-circe").await?;
|
/// client.nick("Not async-circe").await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
NICK(
|
NICK(
|
||||||
/// Nickname
|
/// Nickname
|
||||||
String,
|
String,
|
||||||
),
|
),
|
||||||
/// Authentificate as an operator on a server.
|
/// Authentificate as an operator on a server.
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.oper("username", "password").await?;
|
/// client.oper("username", "password").await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
OPER(
|
OPER(
|
||||||
/// Username
|
/// Username
|
||||||
|
@ -168,15 +141,12 @@ pub enum Command {
|
||||||
/// Everything that is not a command
|
/// Everything that is not a command
|
||||||
OTHER(String),
|
OTHER(String),
|
||||||
/// Leave a channel.
|
/// Leave a channel.
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.part("#main").await?;
|
/// client.part("#main").await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
PART(
|
PART(
|
||||||
/// Target
|
/// Target
|
||||||
|
@ -185,29 +155,23 @@ pub enum Command {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
PASS(String),
|
PASS(String),
|
||||||
/// Tests the presence of a connection to a server.
|
/// Tests the presence of a connection to a server.
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.ping("libera.chat", None).await?;
|
/// client.ping("libera.chat", None).await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
PING(String),
|
PING(String),
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
PONG(String),
|
PONG(String),
|
||||||
/// Send a message to a channel.
|
/// Send a message to a channel.
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.privmsg("#main", "Hello").await?;
|
/// client.privmsg("#main", "Hello").await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
PRIVMSG(
|
PRIVMSG(
|
||||||
/// Source Nickname
|
/// Source Nickname
|
||||||
|
@ -218,15 +182,12 @@ pub enum Command {
|
||||||
String,
|
String,
|
||||||
),
|
),
|
||||||
/// Leave the IRC server you are connected to.
|
/// Leave the IRC server you are connected to.
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.quit(None).await?;
|
/// client.quit(None).await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
QUIT(
|
QUIT(
|
||||||
/// Leave message
|
/// Leave message
|
||||||
|
@ -234,27 +195,21 @@ pub enum Command {
|
||||||
),
|
),
|
||||||
/// Get the topic of a channel.
|
/// Get the topic of a channel.
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.topic("#main", None).await?;
|
/// client.topic("#main", None).await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// Set the topic of a channel.
|
/// Set the topic of a channel.
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.topic("#main", Some("main channel")).await?;
|
/// client.topic("#main", Some("main channel")).await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns IO errors from the TcpStream.
|
/// Returns IO errors from the TcpStream.
|
||||||
|
|
104
src/lib.rs
104
src/lib.rs
|
@ -1,5 +1,5 @@
|
||||||
//! A simple IRC crate written in rust
|
//! A simple IRC crate written in rust
|
||||||
//! ```no_run
|
//! ```run_fut
|
||||||
//! use async_circe::{commands::Command, Client, Config};
|
//! use async_circe::{commands::Command, Client, Config};
|
||||||
//!
|
//!
|
||||||
//! #[tokio::main(flavor = "current_thread")]
|
//! #[tokio::main(flavor = "current_thread")]
|
||||||
|
@ -73,13 +73,10 @@ pub struct Config {
|
||||||
impl Client {
|
impl Client {
|
||||||
/// Creates a new client with a given [`Config`].
|
/// Creates a new client with a given [`Config`].
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// let mut client = Client::new(config).await?;
|
/// let mut client = Client::new(config).await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns error if the client could not connect to the host.
|
/// Returns error if the client could not connect to the host.
|
||||||
|
@ -116,14 +113,11 @@ impl Client {
|
||||||
|
|
||||||
/// Identify user and joins the in the [`Config`] specified channels.
|
/// Identify user and joins the in the [`Config`] specified channels.
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// client.identify().await?;
|
/// client.identify().await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns error if the client could not write to the stream.
|
/// Returns error if the client could not write to the stream.
|
||||||
|
@ -203,9 +197,8 @@ impl Client {
|
||||||
|
|
||||||
/// Read data coming from the IRC as a [`commands::Command`].
|
/// Read data coming from the IRC as a [`commands::Command`].
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
/// # use async_circe::*;
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
|
@ -218,7 +211,6 @@ impl Client {
|
||||||
/// # break;
|
/// # break;
|
||||||
/// }
|
/// }
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns IO errors from the TcpStream.
|
/// Returns IO errors from the TcpStream.
|
||||||
|
@ -248,15 +240,13 @@ impl Client {
|
||||||
|
|
||||||
/// Request information about the admin of a given server.
|
/// Request information about the admin of a given server.
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
/// # use async_circe::*;
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.admin("libera.chat").await?;
|
/// client.admin("libera.chat").await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns IO errors from the TcpStream.
|
/// Returns IO errors from the TcpStream.
|
||||||
|
@ -267,15 +257,12 @@ impl Client {
|
||||||
|
|
||||||
/// Set the status of the client.
|
/// Set the status of the client.
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.away("afk").await?;
|
/// client.away("afk").await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns IO errors from the TcpStream.
|
/// Returns IO errors from the TcpStream.
|
||||||
|
@ -296,15 +283,12 @@ impl Client {
|
||||||
|
|
||||||
/// Invite someone to a channel.
|
/// Invite someone to a channel.
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.invite("liblemonirc", "#async_circe").await?;
|
/// client.invite("liblemonirc", "#async_circe").await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns IO errors from the TcpStream.
|
/// Returns IO errors from the TcpStream.
|
||||||
|
@ -316,15 +300,12 @@ impl Client {
|
||||||
|
|
||||||
/// Join a channel.
|
/// Join a channel.
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.join("#main").await?;
|
/// client.join("#main").await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns IO errors from the TcpStream.
|
/// Returns IO errors from the TcpStream.
|
||||||
|
@ -335,15 +316,12 @@ impl Client {
|
||||||
|
|
||||||
/// List available channels on an IRC, or users in a channel.
|
/// List available channels on an IRC, or users in a channel.
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.list(None, None).await?;
|
/// client.list(None, None).await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns IO errors from the TcpStream.
|
/// Returns IO errors from the TcpStream.
|
||||||
|
@ -362,15 +340,12 @@ impl Client {
|
||||||
|
|
||||||
/// Set the mode for a user.
|
/// Set the mode for a user.
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.mode("test", Some("+B")).await?;
|
/// client.mode("test", Some("+B")).await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns IO errors from the TcpStream.
|
/// Returns IO errors from the TcpStream.
|
||||||
|
@ -385,15 +360,12 @@ impl Client {
|
||||||
|
|
||||||
/// Get all the people online in channels.
|
/// Get all the people online in channels.
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.names("#main,#async_circe", None).await?;
|
/// client.names("#main,#async_circe", None).await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns IO errors from the TcpStream.
|
/// Returns IO errors from the TcpStream.
|
||||||
|
@ -409,15 +381,12 @@ impl Client {
|
||||||
|
|
||||||
/// Change your nickname on a server.
|
/// Change your nickname on a server.
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.nick("Not async-circe").await?;
|
/// client.nick("Not async-circe").await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns IO errors from the TcpStream.
|
/// Returns IO errors from the TcpStream.
|
||||||
|
@ -428,15 +397,12 @@ impl Client {
|
||||||
|
|
||||||
/// Authentificate as an operator on a server.
|
/// Authentificate as an operator on a server.
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.oper("username", "password").await?;
|
/// client.oper("username", "password").await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns IO errors from the TcpStream.
|
/// Returns IO errors from the TcpStream.
|
||||||
|
@ -448,15 +414,12 @@ impl Client {
|
||||||
|
|
||||||
/// Leave a channel.
|
/// Leave a channel.
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.part("#main").await?;
|
/// client.part("#main").await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns IO errors from the TcpStream.
|
/// Returns IO errors from the TcpStream.
|
||||||
|
@ -473,15 +436,12 @@ impl Client {
|
||||||
|
|
||||||
/// Tests the presence of a connection to a server.
|
/// Tests the presence of a connection to a server.
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.ping("libera.chat", None).await?;
|
/// client.ping("libera.chat", None).await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns IO errors from the TcpStream.
|
/// Returns IO errors from the TcpStream.
|
||||||
|
@ -504,15 +464,12 @@ impl Client {
|
||||||
|
|
||||||
/// Send a message to a channel.
|
/// Send a message to a channel.
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.privmsg("#main", "Hello").await?;
|
/// client.privmsg("#main", "Hello").await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns IO errors from the TcpStream.
|
/// Returns IO errors from the TcpStream.
|
||||||
|
@ -524,15 +481,13 @@ impl Client {
|
||||||
|
|
||||||
/// Leave the IRC server you are connected to.
|
/// Leave the IRC server you are connected to.
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
/// # use async_circe::*;
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.quit(None).await?;
|
/// client.quit(None).await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns IO errors from the TcpStream.
|
/// Returns IO errors from the TcpStream.
|
||||||
|
@ -553,27 +508,22 @@ impl Client {
|
||||||
|
|
||||||
/// Get the topic of a channel.
|
/// Get the topic of a channel.
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
/// # use async_circe::*;
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.topic("#main", None).await?;
|
/// client.topic("#main", None).await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// Set the topic of a channel.
|
/// Set the topic of a channel.
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// # #[tokio::main(flavor = "current_thread")]
|
|
||||||
/// # async fn main() -> Result<(), tokio::io::Error> {
|
|
||||||
/// # let config = Default::default();
|
/// # let config = Default::default();
|
||||||
/// # let mut client = Client::new(config).await?;
|
/// # let mut client = Client::new(config).await?;
|
||||||
/// # client.identify().await?;
|
/// # client.identify().await?;
|
||||||
/// client.topic("#main", Some("main channel")).await?;
|
/// client.topic("#main", Some("main channel")).await?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns IO errors from the TcpStream.
|
/// Returns IO errors from the TcpStream.
|
||||||
|
@ -605,6 +555,7 @@ impl Config {
|
||||||
/// Create a new config for the client
|
/// Create a new config for the client
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```rust
|
/// ```rust
|
||||||
|
/// # use async_circe::Config;
|
||||||
/// let config = Config::new(
|
/// let config = Config::new(
|
||||||
/// &["#main", "#async_circe"],
|
/// &["#main", "#async_circe"],
|
||||||
/// "karx.xyz",
|
/// "karx.xyz",
|
||||||
|
@ -659,9 +610,10 @@ impl Config {
|
||||||
|
|
||||||
/// Allows for configuring async-circe at runtime.
|
/// Allows for configuring async-circe at runtime.
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
|
/// # use async_circe::Config;
|
||||||
/// let config = Config::runtime_config(
|
/// let config = Config::runtime_config(
|
||||||
/// vev!["#main".to_string(), "#async_circe".to_string()],
|
/// vec!["#main".to_string(), "#async_circe".to_string()],
|
||||||
/// "karx.xyz".to_string(),
|
/// "karx.xyz".to_string(),
|
||||||
/// Some("+B".to_string()),
|
/// Some("+B".to_string()),
|
||||||
/// Some("async-circe".to_string()),
|
/// Some("async-circe".to_string()),
|
||||||
|
@ -717,7 +669,7 @@ impl Config {
|
||||||
/// port = 6667
|
/// port = 6667
|
||||||
/// username = "circe"
|
/// username = "circe"
|
||||||
/// ```
|
/// ```
|
||||||
/// ```no_run
|
/// ```run_fut
|
||||||
/// let config = Config::from_toml("Config.toml")?;
|
/// let config = Config::from_toml("Config.toml")?;
|
||||||
/// ```
|
/// ```
|
||||||
/// # Errors
|
/// # Errors
|
||||||
|
|
Loading…
Reference in a new issue