Struct markup5ever::buffer_queue::BufferQueue
[−]
[src]
pub struct BufferQueue { /* fields omitted */ }
A queue of owned string buffers, which supports incrementally consuming characters.
Internally it uses VecDeque
and has the same complexity properties.
Methods
impl BufferQueue
[src]
pub fn new() -> BufferQueue
[src]
Create an empty BufferQueue.
pub fn is_empty(&self) -> bool
[src]
Returns whether the queue is empty.
pub fn pop_front(&mut self) -> Option<StrTendril>
[src]
Get the buffer at the beginning of the queue.
pub fn push_front(&mut self, buf: StrTendril)
[src]
Add a buffer to the beginning of the queue.
If the buffer is empty, it will be skipped.
pub fn push_back(&mut self, buf: StrTendril)
[src]
Add a buffer to the end of the queue.
If the buffer is empty, it will be skipped.
pub fn peek(&self) -> Option<char>
[src]
Look at the next available character without removing it, if the queue is not empty.
pub fn next(&mut self) -> Option<char>
[src]
Get the next character if one is available, removing it from the queue.
This function manages the buffers, removing them as they become empty.
pub fn pop_except_from(&mut self, set: SmallCharSet) -> Option<SetResult>
[src]
Pops and returns either a single character from the given set, or a buffer of characters none of which are in the set.
Examples
use markup5ever::buffer_queue::{BufferQueue, SetResult}; let mut queue = BufferQueue::new(); queue.push_back(format_tendril!(r#"<some_tag attr="text">SomeText</some_tag>"#)); let set = small_char_set!(b'<' b'>' b' ' b'=' b'"' b'/'); let tag = format_tendril!("some_tag"); let attr = format_tendril!("attr"); let attr_val = format_tendril!("text"); assert_eq!(queue.pop_except_from(set), Some(SetResult::FromSet('<'))); assert_eq!(queue.pop_except_from(set), Some(SetResult::NotFromSet(tag))); assert_eq!(queue.pop_except_from(set), Some(SetResult::FromSet(' '))); assert_eq!(queue.pop_except_from(set), Some(SetResult::NotFromSet(attr))); assert_eq!(queue.pop_except_from(set), Some(SetResult::FromSet('='))); assert_eq!(queue.pop_except_from(set), Some(SetResult::FromSet('"'))); assert_eq!(queue.pop_except_from(set), Some(SetResult::NotFromSet(attr_val))); // ...
pub fn eat<F: Fn(&u8, &u8) -> bool>(&mut self, pat: &str, eq: F) -> Option<bool>
[src]
Consume bytes matching the pattern, using a custom comparison function eq
.
Returns Some(true)
if there is a match, Some(false)
if there is no match, or None
if
it wasn't possible to know (more data is needed).
The custom comparison function is used elsewhere to compare ascii-case-insensitively.
Examples
use markup5ever::buffer_queue::{BufferQueue}; let mut queue = BufferQueue::new(); queue.push_back(format_tendril!("testtext")); let test_str = "test"; assert_eq!(queue.eat("test", |&a, &b| a == b), Some(true)); assert_eq!(queue.eat("text", |&a, &b| a == b), Some(true)); assert!(queue.is_empty());