1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
#![deny(clippy::all)] #![deny(clippy::cargo)] //! This crate implements a simple irc message wrapper. //! //! This project has 2 goals: //! //! - Ease the access to fields of the message without requiring the user to handle offsets and other IRC related things. //! - Minimize memory foodprint. For this goal the `Message` struct only owns the `String` of the actual message. Any //! parts of the message and other structs only work on references of this string. //! //! Therefore this project expects the strings passed to the struct //! constructors to be valid parts of the IRC standard. //! //! As reference the [RFC2812](https://tools.ietf.org/html/rfc2812) and some extensions //! from [IRCv3](https://ircv3.net/) are used. //! //! # Support //! //! Current support (as of version '0.3.*'): //! //! - **Message**: Create read-only Message from `String` or `&str` and with a builder `Message::builder()`. //! - **Tags**: access through the indexing operator and iterating over all tags. //! - **Prefix**: Read-only access + Builder. //! - **Parameters List**: Read-only access, Iteration over elements, separate access to trailing parameter. //! - **Serde**: Serialization in any format supported by serde. //! //! # Examples - for starters //! //! Simple example with static string: //! //! ```rust //! use irc_rust::Message; //! //! let message = Message::from("@key1=value1;key2=value2 :name!user@host CMD param1 param2 :trailing"); //! //! assert_eq!(message.to_string(), "@key1=value1;key2=value2 :name!user@host CMD param1 param2 :trailing"); //! ``` //! //! While reading from standard input the `Message::from` method has to be used. //! //! ```rust //! use irc_rust::Message; //! use std::io::{BufRead, stdin}; //! //! for line in stdin().lock().lines() { //! match line { //! Ok(line) => { //! let message = Message::from(line); //! println!("> Received command: {}", message.command()); //! } //! Err(e) => { //! println!("got error; aborting: {}", e); //! break; //! } //! } //! } //! //! ``` #[cfg(feature = "serde")] #[macro_use] extern crate serde; mod builder; mod errors; mod message; mod params; mod prefix; mod tags; #[cfg(test)] mod test; pub use builder::Message as MessageBuilder; pub use errors::InvalidIrcFormatError; pub use message::Message; pub use params::Params; pub use prefix::Prefix; pub use tags::Tags;