pub struct Message<const MSG_MAX: usize> { /* private fields */ }
Expand description
This struct holds the message in human readable format.
It also provides functions to do edit position manipulation, getting or setting characters at index positions.
Implementations§
Source§impl<const MSG_MAX: usize> Message<MSG_MAX>
impl<const MSG_MAX: usize> Message<MSG_MAX>
Sourcepub fn iter(&self) -> MessageIterator<'_, MSG_MAX> ⓘ
pub fn iter(&self) -> MessageIterator<'_, MSG_MAX> ⓘ
Get an iterator to the message chars contained within.
Sourcepub fn set_edit_pos(&mut self, pos: usize)
pub fn set_edit_pos(&mut self, pos: usize)
Sets current editing position to given value.
Sourcepub fn set_edit_position_clamp(&mut self, clamp: bool)
pub fn set_edit_position_clamp(&mut self, clamp: bool)
Change the clamping behaviour of the edit position to wrapping (default) or clamping.
With clamping set, when edit position is shifted to left or right, it won’t cycle forward to maximum position or revert back to zero position, effectively remaining within the limits of the message no matter current position is.
pub fn is_edit_clamped(&self) -> bool
Sourcepub fn get_edit_pos(&self) -> usize
pub fn get_edit_pos(&self) -> usize
Returns current editing position.
pub fn get_last_changed_index(&self) -> usize
pub fn get_last_changed_char(&self) -> Character
Sourcepub fn shift_edit_left(&mut self)
pub fn shift_edit_left(&mut self)
Move editing position to the left. By default it will wrap to the end if position is 0
Sourcepub fn shift_edit_right(&mut self)
pub fn shift_edit_right(&mut self)
Move editing position to the right. By default it will wrap to the beginning if position is POS_MAX
Sourcepub fn add_char(&mut self, ch: Character)
pub fn add_char(&mut self, ch: Character)
Insert character at the editing position.
If any characters before the character are FILLERs They’ll automatically be converted to empty characters ’ ’ which means the user wants some space between words.
Sourcepub fn put_char_at(&mut self, index: usize, ch: Character) -> Result<(), &str>
pub fn put_char_at(&mut self, index: usize, ch: Character) -> Result<(), &str>
Insert character at index.
If any characters before the character are FILLERs They’ll automatically be converted to empty characters ’ ’ which means the user wants some space between words.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns current length of the message discarding empty FILLER characters at the end.
This is useful for creating ranged loops of actual characters decoded or can be encoded.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the message is empty, false otherwise.
This method discards FILLER characters and only takes into account normal characters.
Sourcepub fn set_message(
&mut self,
message_str: &str,
edit_pos_end: bool,
) -> Result<(), &str>
pub fn set_message( &mut self, message_str: &str, edit_pos_end: bool, ) -> Result<(), &str>
Manually set the message from an &str.
edit_pos_end flag means we’ll continue from the end of this string when we continue decoding or encoding.
Sourcepub fn as_charray(&self) -> [Character; MSG_MAX]
pub fn as_charray(&self) -> [Character; MSG_MAX]
Returns the message as it is now in a character array format.
Note that this also includes ‘empty’ FILLER characters. Client code can use return value of len() which is the actual length to loop through it or filter the fillers manually in a loop or iterator.