pub struct RingLine<const L: usize, const C: usize> { /* private fields */ }
Expand description
§RingLine
The RingLine structure contains the textual history of a two entity conversation
It is generic over two numbers:
L
is the number of lines it can storeC
is the maximum number of ASCII characters per line
In general, L
should be >= the number of lines you intend to display. If L is
larger than the number of lines you would like to display, it can also be used
as a “scrollback” buffer.
RingLine does NOT store lines in a “sparse” manner - if you have 16 lines and 80 characters per line, 1280 bytes will be used to store those characters, even if all lines are blank.
Implementations§
source§impl<const L: usize, const C: usize> RingLine<L, C>
impl<const L: usize, const C: usize> RingLine<L, C>
pub fn new() -> Self
sourcepub fn iter_history(&self) -> LineIter<'_, L, Line<C>> ⓘ
pub fn iter_history(&self) -> LineIter<'_, L, Line<C>> ⓘ
Iterates all “historical” (e.g. not currently editing) lines, NEWEST to OLDEST
Each line contans a status field that marks it as local or remote.
The returned iterator implements DoubleEndedIterator, and can be reversed with Iterator::rev() to obtain lines in OLDEST to NEWEST order.
sourcepub fn iter_remote_editing(&self) -> LineIter<'_, L, Line<C>> ⓘ
pub fn iter_remote_editing(&self) -> LineIter<'_, L, Line<C>> ⓘ
Iterates any lines that are currently being edited by the remote end, NEWEST to OLDEST
The returned iterator implements DoubleEndedIterator, and can be reversed with Iterator::rev() to obtain lines in OLDEST to NEWEST order.
sourcepub fn local_editing_len(&self) -> usize
pub fn local_editing_len(&self) -> usize
The number of ascii characters/bytes currently used by the local editing buffer
sourcepub fn remote_editing_len(&self) -> usize
pub fn remote_editing_len(&self) -> usize
The number of ascii characters/bytes currently used by the remote editing buffer
sourcepub fn copy_local_editing_to<'a>(
&self,
buffer: &'a mut [u8],
) -> Result<&'a mut [u8], LineError>
pub fn copy_local_editing_to<'a>( &self, buffer: &'a mut [u8], ) -> Result<&'a mut [u8], LineError>
Attempt to copy the entire current local editing buffer to a provided slice
Useful for obtaining the full user input prior to submitting the line.
Returns an error if the provided slice is not large enough to contain the entire local editing buffer contents. Otherwise, returns a subslice that contains the used contents of the provided slice. The length of this slice will be the same as the length returned by RingLine::local_editing_len().
If you do not need the entire contents in a single slice, consider using
RingLine::iter_local_editing() and calling rev()
to get the contents oldest
to newest.
sourcepub fn iter_local_editing(&self) -> LineIter<'_, L, Line<C>> ⓘ
pub fn iter_local_editing(&self) -> LineIter<'_, L, Line<C>> ⓘ
Iterates any lines that are currently being edited by the local end, NEWEST to OLDEST
The returned iterator implements DoubleEndedIterator, and can be reversed with Iterator::rev() to obtain lines in OLDEST to NEWEST order.
sourcepub fn iter_remote_editing_mut(&mut self) -> LineIterMut<'_, '_, L, Line<C>> ⓘ
pub fn iter_remote_editing_mut(&mut self) -> LineIterMut<'_, '_, L, Line<C>> ⓘ
Iterates any lines that are currently being edited by the remote end, NEWEST to OLDEST
The returned iterator implements DoubleEndedIterator, and can be reversed with Iterator::rev() to obtain lines in OLDEST to NEWEST order.
sourcepub fn iter_local_editing_mut(&mut self) -> LineIterMut<'_, '_, L, Line<C>> ⓘ
pub fn iter_local_editing_mut(&mut self) -> LineIterMut<'_, '_, L, Line<C>> ⓘ
Iterates any lines that are currently being edited by the local end, NEWEST to OLDEST
The returned iterator implements DoubleEndedIterator, and can be reversed with Iterator::rev() to obtain lines in OLDEST to NEWEST order.
sourcepub fn submit_local_editing(&mut self)
pub fn submit_local_editing(&mut self)
Moves the local editing region into a user historical region
sourcepub fn submit_remote_editing(&mut self)
pub fn submit_remote_editing(&mut self)
Moves the remote editing region into a user historical region
sourcepub fn append_local_char(&mut self, c: u8) -> Result<(), RingLineError>
pub fn append_local_char(&mut self, c: u8) -> Result<(), RingLineError>
Attempts to append a character to the local editing region
Does NOT accept control characters, such as \n
.
sourcepub fn append_remote_char(&mut self, c: u8) -> Result<(), RingLineError>
pub fn append_remote_char(&mut self, c: u8) -> Result<(), RingLineError>
Attempts to append a character to the remote editing region
Does NOT accept control characters, such as \n
.
sourcepub fn pop_local_char(&mut self)
pub fn pop_local_char(&mut self)
Attempts to remove a character from the local editing region
sourcepub fn pop_remote_char(&mut self)
pub fn pop_remote_char(&mut self)
Attempts to remove a character from the local editing region