Skip to main content

SensitiveDntSink

Struct SensitiveDntSink 

Source
pub struct SensitiveDntSink<P: DntKeyProvider> { /* private fields */ }
Expand description

Encrypted DNT sink. It has no plaintext fallback and must be explicitly wired.

Implementations§

Source§

impl<P: DntKeyProvider> SensitiveDntSink<P>

Source

pub fn new( config: SensitiveDntSinkConfig, key_provider: P, ) -> Result<Self, LogError>

Creates the sink; enabling it is an explicit sensitive-logging decision.

Examples found in repository?
examples/sensitive_diagnostics.rs (lines 31-42)
24fn main() -> Result<(), appcore_log::LogError> {
25    let key_id = KeyId::new("example-log-key").map_err(|_| appcore_log::LogError::Encryption)?;
26
27    let provider =
28        StaticDntKeyProvider::new().with_key(key_id.clone(), SecretKey::new(demo_key()?));
29
30    // The sink bounds the encrypted snapshot by both bytes and event count.
31    let sink = SensitiveDntSink::new(
32        SensitiveDntSinkConfig {
33            path: std::env::temp_dir().join("appcore-sensitive-log.dnt"),
34            application_id: ApplicationId::new("example-log")
35                .map_err(|_| appcore_log::LogError::Encryption)?,
36            key_id,
37            max_bytes: 4096,
38            max_events: 8,
39            retention: 2,
40        },
41        provider,
42    )?;
43
44    // Sensitive mode must be explicit and has no console or JSONL fallback.
45    let mut policy = LogPolicy::default();
46    policy.sensitivity = Sensitivity::Sensitive;
47
48    let log = LogDispatcher::new(policy, vec![Arc::new(sink)]);
49
50    log.event(0, "security").verbosity(2).error("diagnostic");
51
52    Ok(())
53}

Trait Implementations§

Source§

impl<P: DntKeyProvider> LogSink for SensitiveDntSink<P>

Source§

fn emit(&self, event: &LogEvent) -> Result<(), LogError>

Writes one event or reports a controlled failure.
Source§

fn accepts_sensitive(&self) -> bool

Reports whether this sink is an explicitly encrypted sensitive boundary. Read more
Source§

fn name(&self) -> &'static str

Stable bounded metric label for this sink implementation.

Auto Trait Implementations§

§

impl<P> !Freeze for SensitiveDntSink<P>

§

impl<P> !RefUnwindSafe for SensitiveDntSink<P>

§

impl<P> Send for SensitiveDntSink<P>

§

impl<P> Sync for SensitiveDntSink<P>

§

impl<P> Unpin for SensitiveDntSink<P>
where P: Unpin,

§

impl<P> UnsafeUnpin for SensitiveDntSink<P>
where P: UnsafeUnpin,

§

impl<P> UnwindSafe for SensitiveDntSink<P>
where P: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.