OxL Справочник OxL
РусскийEnglish

@ @explicit

@explicit

Применяется к: interface

Раздел: §4.6

Синтаксис

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

Грамматика: Прил. A

Определяется в

Примеры

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     // метод по умолчанию
}

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                      // статическая проверка

— 4.6 Интерфейсы

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               // для oxl export
}

data Event {
  @codec(json: Iso8601) at: Time            // в JSON — строка ISO 8601, в бинарном — по умолчанию
  @codec(Base64Url) token: bytes             // во всех форматах
}

@codec(GeoHashCodec) data Point { lat: f64; lon: f64 }

— 9.5 Пользовательские сериализаторы

Связанные диагностики

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

См. также