pub struct OpenOptions { /* private fields */ }Expand description
Options used to configure how a RotateLog is opened.
Implementations§
Source§impl OpenOptions
impl OpenOptions
Sourcepub fn new() -> Self
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().
Sourcepub fn max_log_count(self, count: u8) -> Self
pub fn max_log_count(self, count: u8) -> Self
Set the maximum Log count.
A larger value would hurt lookup performance.
Sourcepub fn max_bytes_per_log(self, bytes: u64) -> Self
pub fn max_bytes_per_log(self, bytes: u64) -> Self
Set the maximum bytes per Log.
Sourcepub fn checksum_type(self, checksum_type: ChecksumType) -> Self
pub fn checksum_type(self, checksum_type: ChecksumType) -> Self
Sets the checksum type.
See log::ChecksumType for details.
Sourcepub fn create(self, create: bool) -> Self
pub fn create(self, create: bool) -> Self
Set whether create the RotateLog structure if it does not exist.
Sourcepub fn index(
self,
name: &'static str,
func: fn(&[u8]) -> Vec<IndexOutput>,
) -> Self
pub fn index( self, name: &'static str, func: fn(&[u8]) -> Vec<IndexOutput>, ) -> Self
Add an index function.
Sourcepub fn index_defs(self, index_defs: Vec<IndexDef>) -> Self
pub fn index_defs(self, index_defs: Vec<IndexDef>) -> Self
Set the index definitions.
See IndexDef for details.
Sourcepub fn flush_filter(self, flush_filter: Option<FlushFilterFunc>) -> Self
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.
Sourcepub fn auto_sync_threshold(self, threshold: impl Into<Option<u64>>) -> Self
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.
Sourcepub fn open(&self, dir: impl AsRef<Path>) -> Result<RotateLog>
pub fn open(&self, dir: impl AsRef<Path>) -> Result<RotateLog>
Open RotateLog at given location.
Sourcepub fn create_in_memory(&self) -> Result<RotateLog>
pub fn create_in_memory(&self) -> Result<RotateLog>
Open an-empty RotateLog in memory. The RotateLog cannot RotateLog::sync.
Trait Implementations§
Source§impl Clone for OpenOptions
impl Clone for OpenOptions
Source§fn clone(&self) -> OpenOptions
fn clone(&self) -> OpenOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more