OxL Reference

@ @explicit

@explicit

Applies to: interface

Section: §4.6

Syntax

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

Grammar: App. A

Defined in

Examples

oxl
pub(api) interface Storage {
  fn get(k: str) -> bytes?  io
  var fn put(k: str, v: bytes)  io
  fn has(k: str) -> bool  io => get(k) != none     // a default method
}

interface ReadWrite { embed Reader; embed Writer }
interface Container<T> { type Item = T; fn items() -> iter<T> }

@explicit interface Persistent { fn key() -> str }

assert FileStorage: Storage                      // static check

— 4.6 Interfaces

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

explicit-interface, interface-not-satisfied, deprecated, schema-attr, attribute-not-applicable, cache-not-readonly, invalid-window, retry-not-idempotent, rpc-attr

See also