@ @codec
@codec(…)
Applies to: type, field
Section: §9.3–9.5
Syntax
Attr = "@" Path [ "(" [ AttrArgs ] ")" ] ;Grammar: App. A
Defined in
- 9.3 The OxL wire format — The OxL binary format is protobuf 3 encoding with the following mappings
- 9.5 User-defined serialisers — Level 1 — representation through another type (Repr), acts in all formats and in schemas
- 4.9 Attributes — Syntax: @name or @name(arguments) before a declaration, field, parameter or rpc.
Examples
@explicit interface Codec<T> {
static fn encode(x: &T, w: &var Encoder) -> () | EncodeError
static fn decode(r: &var Decoder) -> T | DecodeError
static fn schema() -> Schema // for oxl export
}
data Event {
@codec(json: Iso8601) at: Time // in JSON an ISO 8601 string, in binary the default
@codec(Base64Url) token: bytes // in all formats
}
@codec(GeoHashCodec) data Point { lat: f64; lon: f64 }— 9.5 User-defined serialisers
Related diagnostics
secret-json, schema-attr, deprecated