Editor

Struct Editor 

Source
pub struct Editor<B: Buffer, H: History> { /* private fields */ }
Expand description

Line editor for async IO

It is recommended to use crate::builder::EditorBuilder to build an editor.

Implementations§

Source§

impl<B, H> Editor<B, H>
where B: Buffer, H: History,

Source

pub async fn new<IO: Read + Write>( buffer: LineBuffer<B>, history: H, _io: &mut IO, ) -> Result<Self, NolineError>

Create and initialize line editor

Source

pub async fn readline<'b, 'item, IO, I>( &'b mut self, prompt: impl Into<Prompt<I>>, io: &mut IO, ) -> Result<&'b str, NolineError>
where IO: Read + Write, I: Iterator<Item = &'item str> + Clone,

Read line from stdin

Source

pub fn load_history<'a>( &mut self, entries: impl Iterator<Item = &'a str>, ) -> usize

Load history from iterator

Source

pub fn get_history(&self) -> impl Iterator<Item = CircularSlice<'_>>

Get history as iterator over circular slices

Auto Trait Implementations§

§

impl<B, H> Freeze for Editor<B, H>
where H: Freeze, B: Freeze,

§

impl<B, H> RefUnwindSafe for Editor<B, H>

§

impl<B, H> Send for Editor<B, H>
where H: Send, B: Send,

§

impl<B, H> Sync for Editor<B, H>
where H: Sync, B: Sync,

§

impl<B, H> Unpin for Editor<B, H>
where H: Unpin, B: Unpin,

§

impl<B, H> UnwindSafe for Editor<B, H>
where H: UnwindSafe, B: UnwindSafe,

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.