pub struct FieldEncoding(/* private fields */);Expand description
Values for the encoding byte of a field definition.
The low 5 bits of the encoding byte contain the field’s encoding. The encoding indicates the following information about the field:
-
How the decoder should determine the size of the field. For example,
Value32indicates a 4-byte field,Value128indicates a 16-byte field,ZStringChar8indicates that the field ends at the first char8 unit with value 0, andBinaryLength16Char8indicates that the first 16 bits of the field are the uint16Lengthand that the subsequentLengthchar8 units of the field are the field data. -
How the field should be formatted if the field’s format is
Default(0), unrecognized, or unsupported. For example, aValue32encoding withDefaultor unrecognized format should be treated as if it hadUnsignedIntformat. AStringLength16Char8encoding withDefaultor unrecognized format should be treated as if it hadStringUtfformat. ABinaryLength16Char8encoding withDefaultor unrecognized format should be treated as if it hadHexBytesformat.
The StringLength16Char8 and BinaryLength16Char8 encodings are special.
These encodings can be used with both variable-length (e.g. HexBytes and
String) formats as well as with fixed-length (e.g. UnsignedInt, Float,
IPAddress) formats. When used with fixed-length formats, the semantics depend
on the field’s variable Length (as determined from the first 16 bits of the
field):
-
If the
Lengthis 0, the field is formatted asnull. For example, a field with encoding =BinaryLength16Char8, format =SignedInt, andLength= 0 would be formatted as a null value. -
If the
Lengthis appropriate for the format, the field is formatted as if it had theValue8,Value16,Value32,Value64, orValue128encoding corresponding to its size. For example, a field with encoding =BinaryLength16Char8, format =SignedInt, andLength= 4 would be formatted as an int32 field. -
If the
Lengthis not appropriate for the format, the field is formatted as if it had the default format for the encoding. For example, a field with encoding =BinaryLength16Char8, format =SignedInt, andLength= 16 would be formatted as aHexBytesfield since 16 is not a supported size for theSignedIntformat and the default format forBinaryLength16Char8isHexBytes.
The top 3 bits of the field encoding byte are flags:
-
CArrayFlagindicates that this field is a constant-length array, with the element count specified as a 16-bit value in the event metadata (must not be 0). -
VArrayFlagindicates that this field is a variable-length array, with the element count specified as a 16-bit value in the event payload (immediately before the array elements, may be 0). -
ChainFlagindicates that a format byte is present after the encoding byte. IfChainFlagis not set, the format byte is omitted and is assumed to be 0.
Setting both CArrayFlag and VArrayFlag is invalid (reserved).
Implementations§
Source§impl FieldEncoding
impl FieldEncoding
Sourcepub const Invalid: FieldEncoding
pub const Invalid: FieldEncoding
Invalid encoding value.
Sourcepub const Struct: FieldEncoding
pub const Struct: FieldEncoding
0-byte value, logically groups subsequent N fields, N = format & 0x7F, N must not be 0.
Sourcepub const Value8: FieldEncoding
pub const Value8: FieldEncoding
1-byte value, default format UnsignedInt.
Usable formats: UnsignedInt, SignedInt, HexInt, Boolean, HexBytes, String8.
Sourcepub const Value16: FieldEncoding
pub const Value16: FieldEncoding
2-byte value, default format UnsignedInt.
Usable formats: UnsignedInt, SignedInt, HexInt, Boolean, HexBytes, StringUtf, Port.
Sourcepub const Value32: FieldEncoding
pub const Value32: FieldEncoding
4-byte value, default format UnsignedInt.
Usable formats: UnsignedInt, SignedInt, HexInt, Errno, Pid, Time, Boolean, Float, HexBytes, StringUtf, IPv4.
Sourcepub const Value64: FieldEncoding
pub const Value64: FieldEncoding
8-byte value, default format UnsignedInt.
Usable formats: UnsignedInt, SignedInt, HexInt, Time, Float, HexBytes.
Sourcepub const Value128: FieldEncoding
pub const Value128: FieldEncoding
16-byte value, default format HexBytes.
Usable formats: HexBytes, Uuid, IPv6.
Sourcepub const ZStringChar8: FieldEncoding
pub const ZStringChar8: FieldEncoding
zero-terminated uint8[], default format StringUtf.
Usable formats: HexBytes, String8, StringUtf, StringUtfBom, StringXml, StringJson.
Sourcepub const ZStringChar16: FieldEncoding
pub const ZStringChar16: FieldEncoding
zero-terminated uint16[], default format StringUtf.
Usable formats: HexBytes, StringUtf, StringUtfBom, StringXml, StringJson.
Sourcepub const ZStringChar32: FieldEncoding
pub const ZStringChar32: FieldEncoding
zero-terminated uint32[], default format StringUtf.
Usable formats: HexBytes, StringUtf, StringUtfBom, StringXml, StringJson.
Sourcepub const StringLength16Char8: FieldEncoding
pub const StringLength16Char8: FieldEncoding
uint16 Length followed by uint8 Data[Length], default format StringUtf. Used for string and binary data. Also used for nullable fields.
Usable formats: any.
Sourcepub const StringLength16Char16: FieldEncoding
pub const StringLength16Char16: FieldEncoding
uint16 Length followed by uint16 Data[Length], default format StringUtf.
Usable formats: HexBytes, StringUtf, StringUtfBom, StringXml, StringJson.
Sourcepub const StringLength16Char32: FieldEncoding
pub const StringLength16Char32: FieldEncoding
uint16 Length followed by uint32 Data[Length], default format StringUtf.
Usable formats: HexBytes, StringUtf, StringUtfBom, StringXml, StringJson.
Sourcepub const BinaryLength16Char8: FieldEncoding
pub const BinaryLength16Char8: FieldEncoding
uint16 Length followed by uint8 Data[Length], default format HexBytes. Used for string and binary data. Also used for nullable fields.
Usable formats: any.
Sourcepub const ValueSize: FieldEncoding
pub const ValueSize: FieldEncoding
usize value, default format UnsignedInt.
This is an alias for either Value32 or Value64.
Usable formats: UnsignedInt, SignedInt, HexInt, Time, Float, HexBytes.
Sourcepub const ArrayFlagMask: u8 = 96u8
pub const ArrayFlagMask: u8 = 96u8
Mask for the array flags.
Sourcepub const CArrayFlag: u8 = 32u8
pub const CArrayFlag: u8 = 32u8
Constant-length array: 16-bit element count in metadata (count must not be 0).
Sourcepub const VArrayFlag: u8 = 64u8
pub const VArrayFlag: u8 = 64u8
Variable-length array: 16-bit element count in payload (count may be 0).
Sourcepub const fn from_int(value: u8) -> FieldEncoding
pub const fn from_int(value: u8) -> FieldEncoding
Returns a FieldEncoding with the specified value.
Sourcepub const fn as_int(self) -> u8
pub const fn as_int(self) -> u8
Returns the numeric value corresponding to this FieldEncoding value.
Sourcepub const fn without_flags(self) -> FieldEncoding
pub const fn without_flags(self) -> FieldEncoding
Returns the encoding without any flags (encoding & ValueMask).
Sourcepub const fn with_flags(self, flags: u8) -> FieldEncoding
pub const fn with_flags(self, flags: u8) -> FieldEncoding
Returns the encoding or’ed with the specified flags (encoding | flags).
Sourcepub const fn without_chain_flag(self) -> FieldEncoding
pub const fn without_chain_flag(self) -> FieldEncoding
Returns the encoding without the chain flags (encoding & !ChainFlag).
Sourcepub const fn array_flags(self) -> u8
pub const fn array_flags(self) -> u8
Returns the array flags of the encoding (encoding & (CArrayFlag | VArrayFlag)).
Sourcepub const fn is_array(self) -> bool
pub const fn is_array(self) -> bool
Returns true if any array flag is present (constant-length or variable-length array).
Sourcepub const fn is_constant_length_array(self) -> bool
pub const fn is_constant_length_array(self) -> bool
Returns true if CArrayFlag is present (constant-length array).
Sourcepub const fn is_variable_length_array(self) -> bool
pub const fn is_variable_length_array(self) -> bool
Returns true if VArrayFlag is present (variable-length array).
Sourcepub const fn has_chain_flag(self) -> bool
pub const fn has_chain_flag(self) -> bool
Returns true if ChainFlag is present (format byte is present in event).
Trait Implementations§
Source§impl Clone for FieldEncoding
impl Clone for FieldEncoding
Source§fn clone(&self) -> FieldEncoding
fn clone(&self) -> FieldEncoding
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more