pub struct StdinSource { /* private fields */ }Implementations§
Source§impl StdinSource
impl StdinSource
Sourcepub fn read_all() -> Result<Self>
pub fn read_all() -> Result<Self>
Read all of stdin into a buffer synchronously. After this returns, stdin (fd 0) is at EOF; the caller is responsible for redirecting fd 0 to /dev/tty before entering raw mode if interactive input is needed.
Sourcepub fn spawn_streaming() -> Result<Self>
pub fn spawn_streaming() -> Result<Self>
Duplicate fd 0 onto a private fd, then spawn a thread that reads from
it into a shared buffer. Caller can safely dup2(/dev/tty, 0) afterwards
without disturbing the thread — it reads from the duplicated fd, not
from STDIN_FILENO.
Trait Implementations§
Source§impl Source for StdinSource
impl Source for StdinSource
fn len(&self) -> usize
fn bytes(&self, range: Range<usize>) -> Cow<'_, [u8]>
fn is_complete(&self) -> bool
fn is_empty(&self) -> bool
Source§fn pump(&self)
fn pump(&self)
Read any new bytes that have become available since the last call.
Default no-op for static sources. Streaming sources override.
Source§fn revision(&self) -> u64
fn revision(&self) -> u64
Monotonic counter that bumps whenever the source’s content has been
replaced wholesale (as opposed to merely appended to). Append-style
sources keep this at 0;
LiveFileSource increments it on each detected
rewrite so the event loop knows to rebuild the line index instead of
just folding in new bytes.Source§fn prettify_mode(&self) -> Option<PrettifyMode>
fn prettify_mode(&self) -> Option<PrettifyMode>
Current prettify mode if this source has a
TransformingSource wrapper.
None means the source is not capable of prettification (e.g. a plain
FileSource). Some(Off) means wrapped but currently raw.Source§fn prettify_label(&self) -> Option<String>
fn prettify_label(&self) -> Option<String>
Status-line label for the active prettify state, e.g.
"json" or
"json:err". None when there’s no wrapper or the mode is Off
without an error.Source§fn set_prettify_mode(&self, _mode: PrettifyMode)
fn set_prettify_mode(&self, _mode: PrettifyMode)
Switch to a specific prettify mode. No-op for sources without a wrapper.
Bumps
revision() so callers know to rebuild the line index.Source§fn toggle_prettify(&self)
fn toggle_prettify(&self)
Flip between the current mode and the last active (non-Off) mode.
No-op if the source is not wrapped, or if it has never had an active
mode (i.e. only ever been raw).
Source§fn redetect_prettify(&self)
fn redetect_prettify(&self)
Re-run byte-based content detection and apply the result. Used by the
interactive
-Pa (“auto”) sub-command. No-op without a wrapper.Source§fn take_rotated(&self) -> bool
fn take_rotated(&self) -> bool
Returns true once when the source detected that its backing file
was rotated or truncated. Append-style sources always return false.
FileSource overrides this and consumes the flag on each call so
the app loop only reacts once per event.Auto Trait Implementations§
impl Freeze for StdinSource
impl RefUnwindSafe for StdinSource
impl Send for StdinSource
impl Sync for StdinSource
impl Unpin for StdinSource
impl UnsafeUnpin for StdinSource
impl UnwindSafe for StdinSource
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
Mutably borrows from an owned value. Read more