Struct OpenOptions

Source
pub struct OpenOptions { /* private fields */ }
Expand description

Options used to configure how a RotateLog is opened.

Implementations§

Source§

impl OpenOptions

Source

pub fn new() -> Self

Creates a default new set of options ready for configuration.

The default values are:

  • Keep 2 logs.
  • A log gets rotated when it exceeds 2GB.
  • No indexes.
  • Do not create on demand.
  • Do not sync automatically on append().
Source

pub fn max_log_count(self, count: u8) -> Self

Set the maximum Log count.

A larger value would hurt lookup performance.

Source

pub fn max_bytes_per_log(self, bytes: u64) -> Self

Set the maximum bytes per Log.

Source

pub fn checksum_type(self, checksum_type: ChecksumType) -> Self

Sets the checksum type.

See log::ChecksumType for details.

Source

pub fn create(self, create: bool) -> Self

Set whether create the RotateLog structure if it does not exist.

Source

pub fn index( self, name: &'static str, func: fn(&[u8]) -> Vec<IndexOutput>, ) -> Self

Add an index function.

Source

pub fn index_defs(self, index_defs: Vec<IndexDef>) -> Self

Set the index definitions.

See IndexDef for details.

Source

pub fn flush_filter(self, flush_filter: Option<FlushFilterFunc>) -> Self

Sets the flush filter function.

The function will be called at RotateLog::sync time, if there are changes since open (or last sync) time.

The filter function can be used to avoid writing content that already exists in the latest Log, or rewrite content as needed.

Source

pub fn auto_sync_threshold(self, threshold: impl Into<Option<u64>>) -> Self

Call sync automatically if the in-memory buffer size has exceeded the given size threshold.

This is useful to make in-memory buffer size bounded.

Source

pub fn open(&self, dir: impl AsRef<Path>) -> Result<RotateLog>

Open RotateLog at given location.

Source

pub fn create_in_memory(&self) -> Result<RotateLog>

Open an-empty RotateLog in memory. The RotateLog cannot RotateLog::sync.

Source

pub fn repair(&self, dir: impl AsRef<Path>) -> Result<String>

Try repair all logs in the specified directory.

This just calls into log::OpenOptions::repair recursively.

Trait Implementations§

Source§

impl Clone for OpenOptions

Source§

fn clone(&self) -> OpenOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OpenOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> OpenWithRepair for T
where T: OpenOptionsOutput + OpenOptionsRepair,

Source§

type Output = <T as OpenOptionsOutput>::Output

Source§

fn open_with_repair( &self, path: impl AsRef<Path>, ) -> Result<<T as OpenWithRepair>::Output, Error>

Call open. If it fails with data corruption errors, try repair once, then open again. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more