pub struct Line {
pub tags: HashMap<String, String>,
pub source: Option<String>,
pub command: String,
pub params: Vec<String>,
}
Expand description
A struct representing a parsed line.
Fields§
This line’s tags. This will be an empty hashmap if there are none.
source: Option<String>
This line’s source (including the nick, user, and host). This is
optional, and will be None
if not provided.
command: String
This line’s command.
params: Vec<String>
Any parameters passed to the command. This will be an empty vector if there are none.
Implementations§
Source§impl Line
impl Line
Sourcepub fn new(
tags: HashMap<String, String>,
source: Option<String>,
command: &str,
params: Vec<String>,
) -> Self
pub fn new( tags: HashMap<String, String>, source: Option<String>, command: &str, params: Vec<String>, ) -> Self
Creates a new Line
. You should never call this directly, but
instead use the ircparser::parse function.
§Arguments
tags
- This line’s tags. =source
- This line’s source, orNone
if not to be provided.command
- This line’s command.params
- Any parameters passed to the command.
§Returns
§Example
use std::collections::HashMap;
let mut tags: HashMap<String, String> = HashMap::new();
tags.insert("id".to_string(), "123".to_string());
let source = Some(":nick!user@host.tmi.twitch.tv".to_string());
let command = "PRIVMSG";
let params = vec!["#rickastley".to_string()];
let line = ircparser::Line::new(tags, source, command, params);
assert_eq!(&line.tags["id"], "123");
assert_eq!(line.source.unwrap(), ":nick!user@host.tmi.twitch.tv");
assert_eq!(line.command, "PRIVMSG");
assert_eq!(line.params[0], "#rickastley");
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Line
impl RefUnwindSafe for Line
impl Send for Line
impl Sync for Line
impl Unpin for Line
impl UnwindSafe for Line
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