#[non_exhaustive]pub struct SegmentConfig {
pub flush_policy: FlushPolicy,
pub max_size_bytes: u64,
pub compression_level: i32,
pub durability: DurabilityPolicy,
pub cipher: Option<Arc<dyn SegmentCipher + Send + Sync>>,
}Expand description
Configuration knobs for SegmentBuffer.
This struct is #[non_exhaustive]: new fields may be added in any release
without breaking semver. Construct via SegmentConfig::builder() and then
mutate the public fields you care about, or use SegmentConfig::default()
directly:
use segment_buffer::SegmentConfig;
let mut config = SegmentConfig::default();
config.max_size_bytes = 1024 * 1024;Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.flush_policy: FlushPolicyWhen to auto-flush pending items. See FlushPolicy for the options.
max_size_bytes: u64Max total disk usage before the buffer reports overload pressure (default: 10 GB).
compression_level: i32zstd compression level (1-22; default 1, fastest encode with negligible ratio loss).
durability: DurabilityPolicyPer-flush fsync behavior. See DurabilityPolicy for the three
policies and their crash-loss tradeoffs. Default is
DurabilityPolicy::Throughput (since v0.6.0): the cloud is the
durable layer and this buffer is the throughput buffer. Switch to
DurabilityPolicy::Maximal when this buffer is the last copy.
cipher: Option<Arc<dyn SegmentCipher + Send + Sync>>Optional cipher for encrypting segment files at rest. When None,
segments are written as plaintext zstd+CBOR. Held as an Arc so a
SegmentConfig is Clone and the same cipher can be shared
across multiple buffers or cloned into a recommended_cipher() helper.
Implementations§
Source§impl SegmentConfig
impl SegmentConfig
Sourcepub fn builder() -> SegmentConfigBuilder
pub fn builder() -> SegmentConfigBuilder
Begin a builder. Every field starts at SegmentConfig::default;
chain setter calls to override the ones you care about.
Trait Implementations§
Source§impl Clone for SegmentConfig
impl Clone for SegmentConfig
Source§fn clone(&self) -> SegmentConfig
fn clone(&self) -> SegmentConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SegmentConfig
impl Debug for SegmentConfig
Source§impl Default for SegmentConfig
impl Default for SegmentConfig
Source§impl Display for SegmentConfig
impl Display for SegmentConfig
impl Eq for SegmentConfig
Source§impl PartialEq for SegmentConfig
impl PartialEq for SegmentConfig
Source§fn eq(&self, other: &Self) -> bool
fn eq(&self, other: &Self) -> bool
Compare all configuration knobs by value and the cipher by pointer
identity (Arc::ptr_eq).
The cipher field (Option<Arc<dyn SegmentCipher + Send + Sync>>)
cannot be compared by value because the SegmentCipher trait does not
require PartialEq (comparing key material is a security concern).
Instead, two configs are equal when all scalar knobs match and:
- both ciphers are
None, or - both ciphers point to the same
Arc(pointer identity).
Two separately-constructed ciphers wrapping the same key compare as
not equal. This is intentional — it prevents false positives from
shallow key comparison while still supporting the common test pattern
of cloning a config or sharing a cipher Arc.