Skip to main content

WireRedactor

Struct WireRedactor 

Source
pub struct WireRedactor {
    owners: Vec<Regex>,
}
Expand description

Redacts one captured wire trace. Whole-trace rather than per-line because the identity also leaks as a bare name in prose, which is only recognisable once a home path elsewhere in the file supplies it - from the trace, so the same file redacts identically on any machine.

Fields§

§owners: Vec<Regex>

Implementations§

Source§

impl WireRedactor

Source

pub fn for_trace<'a>( lines: impl IntoIterator<Item = &'a str>, ) -> Result<Self, String>

Discover the home-directory owner(s) named anywhere in lines. A trace naming no home path discovers none, so a bare name in its prose survives.

§Errors

A discovered name below MIN_OWNER_LEN.

Source

pub fn redact_line(&self, line: &str) -> Result<String, String>

Redact one line, by one of three paths: structurally where the no-op round trip is byte-exact; structurally again on a structure-preserving re-encode (a number-token count match - 17-digit floats re-spell under serde_json’s parse, and that is the canonicalisation); by the text rules otherwise, for a non-JSON line or a JSON line with nothing structurally to redact whose re-encode would differ.

§Errors

Serialisation failure, and account or hook-body fields on a line whose re-encode loses structure (a number-token count mismatch - duplicate keys collapse on parse). That arm is LIVE in this build. The message names the frame’s type, never the body it refused to write.

Source

fn redact_structurally(&self, v: Value) -> Result<String, String>

The structural rules plus path and owner scrubbing, over an already-parsed line.

Source

fn scrub_raw(&self, s: &str) -> String

The text rules alone, for a line that must not be re-encoded.

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more