OxL Reference

@ @codec

@codec(…)

Applies to: type, field

Section: §9.3–9.5

Syntax

ebnf
Attr        = "@" Path [ "(" [ AttrArgs ] ")" ] ;

Grammar: App. A

Defined in

Examples

oxl
@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

See also