pub struct Interceptor { /* private fields */ }Expand description
Stateful keystroke interceptor for one wrap session.
Implementations§
Source§impl Interceptor
impl Interceptor
pub fn new(mode: StatementMode) -> Self
Sourcepub fn screen_handle(&self) -> Arc<Mutex<ScreenLine>> ⓘ
pub fn screen_handle(&self) -> Arc<Mutex<ScreenLine>> ⓘ
Shared handle to the echo tracker (for backends that read child output on another thread).
Sourcepub fn on_child_output(&self, bytes: &[u8])
pub fn on_child_output(&self, bytes: &[u8])
Feed child output to the echo tracker.
Sourcepub const fn set_tty_state(&mut self, tty: Option<TtyState>)
pub const fn set_tty_state(&mut self, tty: Option<TtyState>)
Record the child’s terminal mode (call before Self::take_submission).
Sourcepub fn pending(&self) -> &str
pub fn pending(&self) -> &str
Statement text accumulated from previous lines (not yet complete).
Sourcepub const fn editor(&self) -> &LineEditor
pub const fn editor(&self) -> &LineEditor
The editor model (for diagnostics/tests).
Sourcepub const fn needs_echo(&self) -> bool
pub const fn needs_echo(&self) -> bool
The line needs the child’s echo (history, Tab, a stale prompt).
Sourcepub fn echo_confirms_model(&self) -> bool
pub fn echo_confirms_model(&self) -> bool
True when the echo already shows the modelled line (no need to wait for more child output).
Sourcepub fn take_submission(&mut self) -> Submission
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.
Sourcepub fn split_script(dialect: Dialect, text: &str) -> Submission
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.
Sourcepub fn last_prompt(&self) -> Option<&str>
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).
Trait Implementations§
Auto Trait Implementations§
impl Forget for Interceptor
impl Freeze for Interceptor
impl Move for Interceptor
impl RefUnwindSafe for Interceptor
impl Send for Interceptor
impl Sync for Interceptor
impl Unpin for Interceptor
impl UnsafeUnpin for Interceptor
impl UnwindSafe for Interceptor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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