Skip to main content

SegmentConfigBuilder

Struct SegmentConfigBuilder 

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

Ergonomic builder for SegmentConfig.

SegmentConfig is #[non_exhaustive], so direct struct-literal construction is forbidden outside the crate. The builder is the recommended way for callers to override one or two fields without re-typing every default.

use segment_buffer::{FlushPolicy, SegmentConfig};
use std::time::Duration;

let config = SegmentConfig::builder()
    .flush_policy(FlushPolicy::Batch(64))
    .compression_level(6)
    .build();
assert_eq!(config.flush_policy, FlushPolicy::Batch(64));
assert_eq!(config.compression_level, 6);
// Untouched fields fall back to Default.
assert_eq!(config.max_size_bytes, 10 * 1024 * 1024 * 1024);

Implementations§

Source§

impl SegmentConfigBuilder

Source

pub fn flush_policy(self, policy: FlushPolicy) -> Self

Override the auto-flush policy. See FlushPolicy for variants.

Source

pub fn flush_at_batch_size(self, batch_size: usize) -> Self

Convenience: install a FlushPolicy::Batch(batch_size).

Source

pub fn flush_at_interval(self, interval: Duration) -> Self

Convenience: install a FlushPolicy::Interval(interval).

Source

pub fn flush_at_batch_or_interval( self, batch_size: usize, interval: Duration, ) -> Self

Convenience: install a FlushPolicy::BatchOrInterval { .. } with both triggers set.

Source

pub fn flush_manually(self) -> Self

Convenience: install a FlushPolicy::Manual (no auto-flush).

Source

pub fn max_size_bytes(self, max_size_bytes: u64) -> Self

Override the disk-usage ceiling that triggers is_overloaded().

Source

pub fn compression_level(self, compression_level: i32) -> Self

Override the zstd compression level (1–22; 3 is fast with a good ratio).

Source

pub fn cipher(self, cipher: Box<dyn SegmentCipher>) -> Self

Install a SegmentCipher so segment payloads are encrypted at rest.

Source

pub fn build(self) -> SegmentConfig

Materialise the configured SegmentConfig.

Trait Implementations§

Source§

impl Debug for SegmentConfigBuilder

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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