Struct staart::TailedFile

source ·
pub struct TailedFile<T> { /* private fields */ }
Expand description

TailedFile tracks the state of a file being followed. It offers methods for updating this state, and printing data to stdout.

Implementations§

source§

impl<T> TailedFile<T>
where T: AsRef<Path> + Copy,

source

pub fn new(path: T) -> Result<TailedFile<T>, StaartError>

Creates an instance of std::io::Result<staart::TailedFile>

§Example
let mut f = staart::TailedFile::new("/var/log/syslog");
§Propagates Errors
  • If the path provided does not exist, or is not readable by the current user
  • If file metadata can not be read
source

pub fn read(&mut self) -> Result<Vec<u8>, StaartError>

Reads new data for an instance of staart::TailedFile and returns Result<Vec<u8>>

Prior to reading the file, it is checked for rotation and/or truncation.

source

pub fn read_and<F: Fn(&[u8])>(&mut self, f: F) -> Result<(), StaartError>

Passes &Vec<u8> read from the tailed file to a user-defined function returning the unit type ()`.

Auto Trait Implementations§

§

impl<T> Freeze for TailedFile<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for TailedFile<T>
where T: RefUnwindSafe,

§

impl<T> Send for TailedFile<T>
where T: Send,

§

impl<T> Sync for TailedFile<T>
where T: Sync,

§

impl<T> Unpin for TailedFile<T>
where T: Unpin,

§

impl<T> UnwindSafe for TailedFile<T>
where T: UnwindSafe,

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, 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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.