pub struct AnonymizationPolicy {
pub ip_mode: IpAnonymizationMode,
pub mac_mode: MacAnonymizationMode,
pub port_mode: PortAnonymizationMode,
pub timestamp_mode: TimestampAnonymizationMode,
pub tcp_seq_mode: TcpSeqAnonymizationMode,
pub payload_mode: PayloadAnonymizationMode,
pub crypto_pan_key: Option<[u8; 32]>,
pub hash_salt: Option<[u8; 32]>,
}Expand description
Master anonymization policy.
Controls which cryptographic primitives and strategies are applied to each protocol field category during flow export.
§Example
use stackforge_core::anonymize::AnonymizationPolicy;
// ML-optimized defaults: prefix-preserving IPs, hashed MACs,
// well-known ports preserved, epoch-shifted timestamps, payload stripped.
let policy = AnonymizationPolicy::ml_optimized();Fields§
§ip_mode: IpAnonymizationModeIP address anonymization strategy.
mac_mode: MacAnonymizationModeMAC address anonymization strategy (applied if MAC data is present in flow metadata – currently informational for future packet-level anonymization).
port_mode: PortAnonymizationModeTransport port anonymization strategy.
timestamp_mode: TimestampAnonymizationModeTimestamp anonymization strategy.
tcp_seq_mode: TcpSeqAnonymizationModeTCP sequence number anonymization strategy.
payload_mode: PayloadAnonymizationModeReassembled payload handling.
crypto_pan_key: Option<[u8; 32]>32-byte key for Crypto-PAn. First 16 bytes = AES-128 key, last 16 bytes = padding material.
If None and ip_mode is CryptoPan, a random key is generated.
hash_salt: Option<[u8; 32]>32-byte salt for consistent hashing (MAC addresses, connection IDs).
If None, a random salt is generated per engine session.
Implementations§
Source§impl AnonymizationPolicy
impl AnonymizationPolicy
Sourcepub fn ml_optimized() -> Self
pub fn ml_optimized() -> Self
Policy optimized for machine learning on network flows.
- IPs: Crypto-PAn (preserves subnet topology)
- Ports: well-known destination ports preserved
- Timestamps: epoch shift (perfect ordering)
- TCP seq: random per-flow offset
- Payloads: fully truncated
Sourcepub fn maximum_privacy() -> Self
pub fn maximum_privacy() -> Self
Maximum privacy policy. Generalizes all ports, hashes all MACs, and strips payloads.
Trait Implementations§
Source§impl Clone for AnonymizationPolicy
impl Clone for AnonymizationPolicy
Source§fn clone(&self) -> AnonymizationPolicy
fn clone(&self) -> AnonymizationPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AnonymizationPolicy
impl Debug for AnonymizationPolicy
Auto Trait Implementations§
impl Freeze for AnonymizationPolicy
impl RefUnwindSafe for AnonymizationPolicy
impl Send for AnonymizationPolicy
impl Sync for AnonymizationPolicy
impl Unpin for AnonymizationPolicy
impl UnsafeUnpin for AnonymizationPolicy
impl UnwindSafe for AnonymizationPolicy
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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