pub struct TerminalEventBuffer { /* private fields */ }Expand description
Cloneable single-threaded FIFO event source.
Clones share the same Rc<RefCell<_>> queue. Reentrant mutable access panics
according to RefCell rules; the type is not thread-safe.
§Examples
use ailloli_ui_widgets::controls::{TerminalEvent, TerminalEventBuffer, TerminalEventSource};
let writer = TerminalEventBuffer::new();
let reader = writer.clone();
writer.push(TerminalEvent::clear(1));
assert_eq!(reader.drain_events().len(), 1);Implementations§
Source§impl TerminalEventBuffer
impl TerminalEventBuffer
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty shared queue.
§Examples
use ailloli_ui_widgets::controls::TerminalEventBuffer;
assert!(TerminalEventBuffer::new().is_empty());Sourcepub fn push(&self, event: TerminalEvent)
pub fn push(&self, event: TerminalEvent)
Appends one event to the FIFO tail.
§Panics
Panics if the shared queue is already mutably borrowed reentrantly.
§Examples
use ailloli_ui_widgets::controls::{TerminalEvent, TerminalEventBuffer};
let buffer = TerminalEventBuffer::new();
buffer.push(TerminalEvent::clear(1));
assert!(!buffer.is_empty());Sourcepub fn extend(&self, events: impl IntoIterator<Item = TerminalEvent>)
pub fn extend(&self, events: impl IntoIterator<Item = TerminalEvent>)
Appends events to the FIFO tail in iterator order.
§Panics
Panics if the shared queue is already mutably borrowed reentrantly.
§Examples
use ailloli_ui_widgets::controls::{TerminalEvent, TerminalEventBuffer, TerminalEventSource};
let buffer = TerminalEventBuffer::new();
buffer.extend([TerminalEvent::clear(1), TerminalEvent::clear(2)]);
assert_eq!(buffer.drain_events().len(), 2);Trait Implementations§
Source§impl Clone for TerminalEventBuffer
impl Clone for TerminalEventBuffer
Source§fn clone(&self) -> TerminalEventBuffer
fn clone(&self) -> TerminalEventBuffer
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for TerminalEventBuffer
impl Default for TerminalEventBuffer
Source§fn default() -> TerminalEventBuffer
fn default() -> TerminalEventBuffer
Returns the “default value” for a type. Read more
Source§impl TerminalEventSource for TerminalEventBuffer
impl TerminalEventSource for TerminalEventBuffer
Source§fn drain_events(&self) -> Vec<TerminalEvent>
fn drain_events(&self) -> Vec<TerminalEvent>
Drains every queued event in FIFO order.
Auto Trait Implementations§
impl Freeze for TerminalEventBuffer
impl !RefUnwindSafe for TerminalEventBuffer
impl !Send for TerminalEventBuffer
impl !Sync for TerminalEventBuffer
impl Unpin for TerminalEventBuffer
impl !UnwindSafe for TerminalEventBuffer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
§fn into_click_action(self) -> ClickAction<A>
fn into_click_action(self) -> ClickAction<A>
Implements the into_click_action helper used by this module.