pub enum Word<'a> {
Category(WordCategory),
Tag(u16),
Attribute(WordAttribute<'a>),
Message(&'a str),
}Expand description
Represents a word in a Mikrotik [Sentence].
Words can be of three types:
- A category word, which represents the type of sentence, such as
!done,!re,!trap, or!fatal. - A tag word, which represents a tag value like
.tag=123. - An attribute word, which represents a key-value pair like
=name=ether1.
The word can be converted into one of these types using the TryFrom trait.
§Examples
use mikrotik::command::reader::Word;
let word = Word::try_from(b"=name=ether1");
assert_eq!(word.unwrap().attribute(), Some(("name", Some("ether1"))));Variants§
Category(WordCategory)
A category word, such as !done, !re, !trap, or !fatal.
Tag(u16)
A tag word, such as .tag=123.
Attribute(WordAttribute<'a>)
An attribute word, such as =name=ether1.
Message(&'a str)
An unrecognized word. Usually this is a !fatal reason message.
Implementations§
Source§impl Word<'_>
impl Word<'_>
Sourcepub fn category(&self) -> Option<&WordCategory>
pub fn category(&self) -> Option<&WordCategory>
Returns the category of the word, if it is a category word.
Sourcepub fn attribute(&self) -> Option<(&str, Option<&str>)>
pub fn attribute(&self) -> Option<(&str, Option<&str>)>
Returns the attribute of the word, if it is an attribute word.
Trait Implementations§
impl<'a> StructuralPartialEq for Word<'a>
Auto Trait Implementations§
impl<'a> Freeze for Word<'a>
impl<'a> RefUnwindSafe for Word<'a>
impl<'a> Send for Word<'a>
impl<'a> Sync for Word<'a>
impl<'a> Unpin for Word<'a>
impl<'a> UnwindSafe for Word<'a>
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