[][src]Struct rmesg::klogctl::KLogEntries

pub struct KLogEntries { /* fields omitted */ }

While reading the kernel log buffer is very useful in and of itself (expecially when running the CLI), a lot more value is unlocked when it can be tailed line-by-line.

This struct provides the facilities to do that. It implements an iterator to easily iterate indefinitely over the lines.

IMPORTANT NOTE: This iterator makes a best-effort attempt at eliminating duplicate lines so that it can only provide newer lines upon each iteration. The way it accomplishes this is by using the timestamp field, to track the last-seen timestamp of a line already buffered, and this only consuming lines past that timestamp on each poll.

The timestamp may not always be set in kernel logs. The iterator will ignore lines without a timestamp. It is left to the consumers of this struct to ensure the timestamp is set, if they wish for lines to not be ignored. In order to aid this, two functions are provided in this crate to check kernel_log_timestamps_enabled and to set or unset kernel_log_timestamps_enable.

The UX is left to the consumer.

Implementations

impl KLogEntries[src]

pub fn with_options(
    clear: bool,
    poll_interval: Duration
) -> Result<KLogEntries, RMesgError>
[src]

Create a new KLogEntries with two specific options clear: bool specifies Whether or not to clear the buffer after every read. poll_interval: Duration specifies the interval after which to poll the buffer for new lines

Choice of these parameters affects how the iterator behaves significantly.

When clear is set, the buffer is cleared after each read. This means other utilities on the system that may also be reading the buffer will miss lines/data as it may be cleared before they can read it. This is a destructive option provided for completeness.

The poll interval determines how frequently KLogEntries polls for new content. If the poll interval is too short, the iterator will eat up resources for no benefit. If it is too long, then any lines that showed up and were purged between the two polls will be lost.

This crate exports a constant SUGGESTED_POLL_INTERVAL which contains the recommended default when in doubt.

Trait Implementations

impl Stream for KLogEntries[src]

Trait to iterate over lines of the kernel log buffer.

type Item = Result<Entry, RMesgError>

Values yielded by the stream.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StreamExt for T where
    T: Stream + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<S, T, E> TryStream for S where
    S: Stream<Item = Result<T, E>> + ?Sized
[src]

type Ok = T

The type of successful values yielded by this future

type Error = E

The type of failures yielded by this future

impl<S> TryStreamExt for S where
    S: TryStream + ?Sized
[src]