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

method Codec.schema

The protobuf type text of the codec's representation, recorded in oxl.schema.lock and used by oxl export.

Example:

oxl✓ проверяется в CI
use std.ser { Codec, Encoder, Decoder, Schema, encode, decode, hex, EncodeError, DecodeError }

data Shift {}

impl Codec<i64> for Shift {
  static fn encode(x: &i64, w: &var Encoder) -> () | EncodeError { w.writeI64(x + 1) }
  static fn decode(r: &var Decoder) -> i64 | DecodeError { r.readI64()? - 1 }
  static fn schema() -> Schema => Schema.of("int64")
}

fn main() io {
  print(Shift.schema().proto)
}
Вывод
int64
static fn schema() -> Schema

С версии. 1.0.0-beta

Возвращает

Schema

Эффекты

не объявлены (чистая, пока тело не говорит иное)

Определено в: std/ser/ser.oxl:329

См. также