VtMachine

Struct VtMachine 

Source
pub struct VtMachine { /* private fields */ }
Expand description

Virtual terminal state machine.

This is the main type in this crate, which takes Unicode scalar values and translates them into low-level events to be interpreted by a higher-level terminal emulator implementation.

VtMachine implements a Unicode-native terminal state machine that does not support any legacy character encodings. If working with a raw byte stream, such as from a pseudoterminal provided by the host OS, the caller must first interpret the bytes as UTF-8 sequences and provide the result to either VtMachine::write_u8char.

This implementation is not suitable for emulating a legacy hardware video terminal that used switchable character sets.

Implementations§

Source§

impl VtMachine

Source

pub const fn new() -> Self

Constructs a new VtMachine.

Source

pub fn write_u8char<'m>( &'m mut self, c: u8char, ) -> impl Iterator<Item = VtEvent<'m>>

Consumes a single unicode scalar value given as a u8char, returning a series of events that the character causes.

The caller should consume the entire iterator in order to stay properly synchronized with the VtMachine.

Source

pub fn write_char<'m>( &'m mut self, c: char, ) -> impl Iterator<Item = VtEvent<'m>>

Consumes a single unicode scalar value given as a char.

Note that VtMachine uses u8char as its primary representation of characters, and so this function is really just converting the given char to u8char and then passing it to Self::write_u8char. If you already have a u8char value then it’s better to use the other function directly.

Source

pub fn write_end(&mut self) -> impl Iterator<Item = VtEvent<'static>>

Tells the VtMachine that no more bytes are expected, such as if the stream that the data is arriving from is closed from the writer end.

This can potentially return some final events caused by ending sequences that had not yet been explicitly terminated.

It’s okay to keep using the VtMachine after calling this function, but any subsequent character written will be treated as if it is the first character in a new stream.

Auto Trait Implementations§

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>,

Source§

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>,

Source§

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.