[−][src]Enum twitch_irc::message::IRCPrefix
A "prefix" part of an IRC message, as defined by RFC 2812:
<prefix> ::= <servername> | <nick> [ '!' <user> ] [ '@' <host> ]
<servername> ::= <host>
<nick> ::= <letter> { <letter> | <number> | <special> }
<user> ::= <nonwhite> { <nonwhite> }
<host> ::= see RFC 952 [DNS:4] for details on allowed hostnames
<letter> ::= 'a' ... 'z' | 'A' ... 'Z'
<number> ::= '0' ... '9'
<special> ::= '-' | '[' | ']' | '\' | '`' | '^' | '{' | '}'
<nonwhite> ::= <any 8bit code except SPACE (0x20), NUL (0x0), CR
(0xd), and LF (0xa)>
Examples
use twitch_irc::message::IRCPrefix; use twitch_irc::message::AsRawIRC; let prefix = IRCPrefix::Full { nick: "a_nick".to_owned(), user: Some("a_user".to_owned()), host: Some("a_host.com".to_owned()) }; assert_eq!(prefix.as_raw_irc(), "a_nick!a_user@a_host.com");
use twitch_irc::message::IRCPrefix; use twitch_irc::message::AsRawIRC; let prefix = IRCPrefix::Full { nick: "a_nick".to_owned(), user: None, host: Some("a_host.com".to_owned()) }; assert_eq!(prefix.as_raw_irc(), "a_nick@a_host.com");
use twitch_irc::message::IRCPrefix; use twitch_irc::message::AsRawIRC; let prefix = IRCPrefix::HostOnly { host: "a_host.com".to_owned() }; assert_eq!(prefix.as_raw_irc(), "a_host.com");
Variants
The prefix specifies only a sending server/hostname.
Note that the spec also allows a very similar format where only a sending nickname is
specified. However that type of format plays no role on Twitch, and is practically impossible
to reliably tell apart from host-only prefix messages. For this reason, a prefix without
a @
character is always assumed to be purely a host-only prefix, and not a nickname-only prefix.
Fields of HostOnly
host: String
host
part of the prefix
The prefix variant specifies a nickname, and optionally also a username and optionally a hostname. See above for the RFC definition.
Fields of Full
Implementations
impl IRCPrefix
[src]
pub fn parse(source: &str) -> IRCPrefix
[src]
Parse the IRCPrefix
from the given string slice. source
should be specified without
the leading :
that precedes in full IRC messages.
Examples
use twitch_irc::message::IRCPrefix; let prefix = IRCPrefix::parse("a_nick!a_user@a_host.com"); assert_eq!(prefix, IRCPrefix::Full { nick: "a_nick".to_owned(), user: Some("a_user".to_owned()), host: Some("a_host.com".to_owned()) })
use twitch_irc::message::IRCPrefix; let prefix = IRCPrefix::parse("a_host.com"); assert_eq!(prefix, IRCPrefix::HostOnly { host: "a_host.com".to_owned() })
Trait Implementations
impl AsRawIRC for IRCPrefix
[src]
fn format_as_raw_irc(&self, f: &mut Formatter<'_>) -> Result<(), Error>
[src]
fn as_raw_irc(&self) -> String where
Self: Sized,
[src]
Self: Sized,
impl Clone for IRCPrefix
[src]
impl Debug for IRCPrefix
[src]
impl Hash for IRCPrefix
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<IRCPrefix> for IRCPrefix
[src]
impl StructuralPartialEq for IRCPrefix
[src]
Auto Trait Implementations
impl RefUnwindSafe for IRCPrefix
impl Send for IRCPrefix
impl Sync for IRCPrefix
impl Unpin for IRCPrefix
impl UnwindSafe for IRCPrefix
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,