Skip to main content

Interceptor

Struct Interceptor 

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

Stateful keystroke interceptor for one wrap session.

Implementations§

Source§

impl Interceptor

Source

pub fn new(mode: StatementMode) -> Self

Source

pub fn screen_handle(&self) -> Arc<Mutex<ScreenLine>> ⓘ

Shared handle to the echo tracker (for backends that read child output on another thread).

Source

pub fn on_child_output(&self, bytes: &[u8])

Feed child output to the echo tracker.

Source

pub fn set_size(&self, cols: usize, rows: usize)

Tell the echo tracker the terminal size.

Source

pub const fn set_tty_state(&mut self, tty: Option<TtyState>)

Record the child’s terminal mode (call before Self::take_submission).

Source

pub fn pending(&self) -> &str

Statement text accumulated from previous lines (not yet complete).

Source

pub fn delimiter(&self) -> &str

The current statement delimiter (mysql DELIMITER changes it).

Source

pub const fn editor(&self) -> &LineEditor

The editor model (for diagnostics/tests).

Source

pub const fn needs_echo(&self) -> bool

The line needs the child’s echo (history, Tab, a stale prompt).

Source

pub fn feed_key(&mut self, byte: u8) -> KeyEvent

Feed one byte typed by the user.

Source

pub fn echo_confirms_model(&self) -> bool

True when the echo already shows the modelled line (no need to wait for more child output).

Source

pub fn take_submission(&mut self) -> Submission

Called when Enter was pressed (and child output drained). Consumes the current line and returns what must be checked.

Source

pub fn split_script(dialect: Dialect, text: &str) -> Submission

What a script file runs when the client reads it (\i, source, \., .read, load()), following the same client model as typed input: mysql DELIMITER / \d, psql \set variables, line commands (source, system, .read, .shell) and backslash meta-commands. Nested includes come back as MetaKind::RunFile metas; the caller decides whether to follow them.

See ScriptReader to read a large script line by line.

Source

pub fn last_prompt(&self) -> Option<&str>

The prompt captured for the most recently submitted line (used to repaint it after a discard the child does not redraw itself).

Source

pub fn discard(&mut self)

Forget the current line and pending statement (after a discard).

Trait Implementations§

Source§

impl Debug for Interceptor

Source§

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

Formats the value using the given formatter. Read more

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more