pub enum Content {
Show 18 variants Bool(bool), U8(u8), U16(u16), U32(u32), U64(u64), U128(u128), I8(i8), I16(i16), I32(i32), I64(i64), I128(i128), F32(f32), F64(f64), Char(char), String(String), Bytes(Vec<u8>), Seq(Vec<Content>), Map(Vec<(Content, Content)>), // some variants omitted
}
Expand description

Represents variable typed content.

This is used for the serialization system to represent values before the actual snapshots are written and is also exposed to dynamic redaction functions.

Some enum variants are intentionally not exposed to user code. It’s generally recommended to construct content objects by using the From trait and by using the accessor methods to assert on it.

While matching on the content is possible in theory it is recommended against. The reason for this is that the content enum holds variants that can “wrap” values where it’s not expected. For instance if a field holds an Option<String> you cannot use pattern matching to extract the string as it will be contained in an internal Some variant that is not exposed. On the other hand the as_str method will automatically resolve such internal wrappers.

If you do need to pattern match you should use the resolve_inner method to resolve such internal wrappers.

Variants

Bool(bool)

U8(u8)

U16(u16)

U32(u32)

U64(u64)

U128(u128)

I8(i8)

I16(i16)

I32(i32)

I64(i64)

I128(i128)

F32(f32)

F64(f64)

Char(char)

String(String)

Bytes(Vec<u8>)

Seq(Vec<Content>)

Map(Vec<(Content, Content)>)

Implementations

This resolves the innermost content in a chain of wrapped content.

For instance if you encounter an Option<Option<String>> field the content will be wrapped twice in an internal option wrapper. If you need to pattern match you will need in some situations to first resolve the inner value before such matching can take place as there is no exposed way to match on these wrappers.

This method does not need to be called for the as_ methods which resolve automatically.

Mutable version of resolve_inner.

Returns the value as string

Returns the value as bytes

Returns the value as slice of content values.

Returns true if the value is nil.

Returns the value as bool

Returns the value as u64

Returns the value as u128

Returns the value as i64

Returns the value as i128

Returns the value as f64

Recursively walks the content structure mutably.

The callback is invoked for every content in the tree.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.