Skip to main content

Completer

Trait Completer 

Source
pub trait Completer {
    type Candidate: Candidate;

    // Provided methods
    fn complete(
        &self,
        line: &str,
        pos: usize,
        ctx: &Context<'_>,
    ) -> Result<(usize, Vec<Self::Candidate>)> { ... }
    fn update(
        &self,
        line: &mut LineBuffer,
        start: usize,
        elected: &str,
        cl: &mut Changeset,
    ) { ... }
}
Expand description

To be called for tab-completion.

Required Associated Types§

Source

type Candidate: Candidate

Specific completion candidate.

Provided Methods§

Source

fn complete( &self, line: &str, pos: usize, ctx: &Context<'_>, ) -> Result<(usize, Vec<Self::Candidate>)>

Takes the currently edited line with the cursor position and returns the start position and the completion candidates for the partial word to be completed.

("ls /usr/loc", 11) => Ok((3, vec!["/usr/local/"]))

Source

fn update( &self, line: &mut LineBuffer, start: usize, elected: &str, cl: &mut Changeset, )

Updates the edited line with the elected candidate.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Completer for ()

Source§

type Candidate = String

Source§

fn update( &self, _line: &mut LineBuffer, _start: usize, _elected: &str, _cl: &mut Changeset, )

Source§

impl<C: ?Sized + Completer> Completer for Arc<C>

Source§

type Candidate = <C as Completer>::Candidate

Source§

fn complete( &self, line: &str, pos: usize, ctx: &Context<'_>, ) -> Result<(usize, Vec<Self::Candidate>)>

Source§

fn update( &self, line: &mut LineBuffer, start: usize, elected: &str, cl: &mut Changeset, )

Source§

impl<C: ?Sized + Completer> Completer for Box<C>

Source§

type Candidate = <C as Completer>::Candidate

Source§

fn complete( &self, line: &str, pos: usize, ctx: &Context<'_>, ) -> Result<(usize, Vec<Self::Candidate>)>

Source§

fn update( &self, line: &mut LineBuffer, start: usize, elected: &str, cl: &mut Changeset, )

Source§

impl<C: ?Sized + Completer> Completer for Rc<C>

Source§

type Candidate = <C as Completer>::Candidate

Source§

fn complete( &self, line: &str, pos: usize, ctx: &Context<'_>, ) -> Result<(usize, Vec<Self::Candidate>)>

Source§

fn update( &self, line: &mut LineBuffer, start: usize, elected: &str, cl: &mut Changeset, )

Implementors§