Field-type
Field is the public structured metadata item type used on records, logger context, filters, and patch helpers. It is a direct alias to the core record field model that stores one key and one value string.
Interface
pub type Field = @core.Fieldoutput
Field- Public structured field value containingkeyandvaluetext.
Explanation
Detailed rules explaining key parameters and behaviors
- This is a type alias, not a constructor helper by itself.
- The current fields are
key : Stringandvalue : String. field(...)andfields(...)construct this type as the main public helpers.- The same value type is consumed by
Record::new(...),Logger::bind(...), write APIs that acceptfields, field-based predicates, and record patch helpers.
How to Use
Here are some specific examples provided.
When Need A Typed Reusable Metadata Value
When one field should be created once and reused across records or loggers:
let service_field : Field = field("service", "billing")In this example, the metadata stays as a typed reusable value instead of being rebuilt inline each time.
When Need To Attach Structured Context To A Record
When code should pass field values into record creation directly:
let rec = Record::new(Level::Info, "accepted", fields=[field("user", "alice")])In this example, the field type becomes part of the record's structured metadata payload.
Error Case
e.g.:
Fielditself does not have a runtime failure mode.Empty keys or values are still stored as-is because the type is plain structured data rather than a validated schema.
Notes
Use
field(...)when you need a value of this type in code.Use arrays of
Fieldwhen attaching multiple metadata entries to records, loggers, or global emitters.