OxL Reference

method Codec.schema

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

Example:

oxl✓ checked in 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)
}
Output
int64
static fn schema() -> Schema

Since. 1.0.0-beta

Returns

Schema

Effects

none declared (pure unless the body says otherwise)

Defined in: std/ser/ser.oxl:329

See also