Struct input_mgr::Line

source ·
pub struct Line<const C: usize> { /* private fields */ }
Expand description

A single line with fixed capacity for C characters

At the moment, C must be <= 255.

This Line acts more or less like a small, fixed size vector of ascii characters

Lines ONLY contain valid ascii characters, that are not control characters.

Implementations§

source§

impl<const C: usize> Line<C>

source

pub const fn new() -> Self

Create a new empty line

source

pub fn status(&self) -> Source

The source of the current line, either Local or Remote

source

pub fn len(&self) -> usize

The currently used number of bytes in this line

source

pub fn is_empty(&self) -> bool

Is the current line empty?

source

pub fn is_full(&self) -> bool

Is the current line full?

source

pub fn pop(&mut self)

Pop a character from the END of the line (if any)

source

pub fn as_str(&self) -> &str

Obtain the current line as a &str

source

pub const fn cap_u8() -> u8

source

pub fn extend(&mut self, s: &str) -> Result<(), LineError>

Extend the current line with the given string slice.

Returns an error if the provided slice would not fit, or if any characters are invalid ascii or ascii control characters

source

pub fn overwrite(&mut self, pos: usize, ovrw: u8) -> Result<(), LineError>

Overwrite an ascii character at the given position

Returns an error if the provided location would leave a gap (beyond the end of the current line), or if the given character is invalid ascii or an ascii control character

source

pub fn not_full(&self) -> Result<(), LineError>

Returns an error if the line is full

source

pub fn push(&mut self, ins: u8) -> Result<(), LineError>

Push an ascii character to the end of the line

Returns an error if the provided character would not fit, or if the character is invalid ascii or an ascii control character

source

pub fn insert(&mut self, pos: usize, ins: u8) -> Result<(), LineError>

Insert an ascii character at the given position

Returns an error if the provided location would leave a gap (beyond the end of the current line), or if the given character is invalid ascii or an ascii control character, or if the line is already full

Trait Implementations§

source§

impl<const C: usize> Debug for Line<C>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<const C: usize> Freeze for Line<C>

§

impl<const C: usize> RefUnwindSafe for Line<C>

§

impl<const C: usize> Send for Line<C>

§

impl<const C: usize> Sync for Line<C>

§

impl<const C: usize> Unpin for Line<C>

§

impl<const C: usize> UnwindSafe for Line<C>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.