pub struct RollingFileWriter {
base_path: PathBuf,
max_bytes: u64,
max_files: usize,
file: BufWriter<File>,
current_size: u64,
}Expand description
Rotation is decided from the current write call’s length, so a
caller must hand over one whole record per call and keep it under
the buffer capacity - a partial write re-enters the check with only
the remainder.
Fields§
§base_path: PathBuf§max_bytes: u64§max_files: usize§file: BufWriter<File>§current_size: u64Implementations§
Trait Implementations§
Source§impl Debug for RollingFileWriter
impl Debug for RollingFileWriter
Source§impl Write for RollingFileWriter
impl Write for RollingFileWriter
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Writes a buffer into this writer, returning how many bytes were written. Read more
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flushes this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
write_all_vectored)Attempts to write multiple buffers into this writer. Read more
Auto Trait Implementations§
impl Freeze for RollingFileWriter
impl RefUnwindSafe for RollingFileWriter
impl Send for RollingFileWriter
impl Sync for RollingFileWriter
impl Unpin for RollingFileWriter
impl UnsafeUnpin for RollingFileWriter
impl UnwindSafe for RollingFileWriter
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> ⓘ
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 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> ⓘ
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
§impl<W> WriteSamples for W
impl<W> WriteSamples for W
§fn write_sample<T>(&mut self, sample: &T) -> Result<(), Error>where
T: BytesSample,
fn write_sample<T>(&mut self, sample: &T) -> Result<(), Error>where
T: BytesSample,
Write a single sample to the underlying writer. Read more
§fn write_number<T>(
&mut self,
value: <T as BytesSample>::NumericType,
) -> Result<(), Error>where
T: BytesSample,
fn write_number<T>(
&mut self,
value: <T as BytesSample>::NumericType,
) -> Result<(), Error>where
T: BytesSample,
Write a single sample from a numeric type to the underlying writer. Read more
§fn write_converted<T, U>(&mut self, value: U) -> Result<bool, Error>where
T: RawSample + BytesSample,
U: FloatCore + ToPrimitive,
fn write_converted<T, U>(&mut self, value: U) -> Result<bool, Error>where
T: RawSample + BytesSample,
U: FloatCore + ToPrimitive,
Write a single converted sample to the underlying writer. Read more
§fn write_all_samples<T>(&mut self, samples: &[T]) -> Result<(), Error>where
T: BytesSample,
fn write_all_samples<T>(&mut self, samples: &[T]) -> Result<(), Error>where
T: BytesSample,
Write multiple samples to the underlying writer. Read more
§fn write_all_numbers<T>(
&mut self,
values: &[<T as BytesSample>::NumericType],
) -> Result<(), Error>where
T: BytesSample,
fn write_all_numbers<T>(
&mut self,
values: &[<T as BytesSample>::NumericType],
) -> Result<(), Error>where
T: BytesSample,
Write multiple samples from a numeric slice to the underlying writer. Read more
§fn write_all_converted<T, U>(&mut self, values: &[U]) -> Result<usize, Error>where
T: RawSample + BytesSample,
U: FloatCore + ToPrimitive,
fn write_all_converted<T, U>(&mut self, values: &[U]) -> Result<usize, Error>where
T: RawSample + BytesSample,
U: FloatCore + ToPrimitive,
Write multiple converted samples from a float slice to the underlying writer. Read more