moon/fory Apache Fory · MoonBit

API · struct

Config

Configuration · defined at config.mbt:12

pub(all) struct Config {
  xlang : Bool
  track_ref : Bool
  check_string : Bool
  depth : Int32
  fields : Int32
  graph : Int32
}

What a reader will accept and what a writer will send.

Every default here is the Rust fory crate's Config::default(), because that is the reference implementation the specification names first, and because a default nobody else shares is a default an interop test finds. Where this package has no counterpart for one of its knobs — the schema version check, the type-meta cache — the knob is absent rather than inert.

Fields

FieldMeaning
xlang : Bool

Whether the header byte carries the cross-language flag.

The xlang format is the one implemented here, so this is true; a writer asked for false writes a header without the flag, and a reader asked for true refuses one.

track_ref : Bool

Whether values that are written more than once, or that take part in a cycle, are sent once and pointed at afterwards.

Off by default, as in the Rust crate: reference tracking costs a byte per tracked value and a table on both sides, which a graph without sharing should not pay for. Turn it on and mark the shared nodes with shared.

check_string : Bool

Whether the bytes of a string are checked as UTF-8 before they become a String.

On by default, as in the Rust crate. Turning it off is a promise that the peer is trusted, not a way to read a string that is not one.

depth : Int32

How deeply values may nest before a message is refused.

Five is the Rust crate's max_dyn_depth. A message of ten thousand open lists is a denial of service rather than a message, and the depth is the one number that stops it before the stack does.

fields : Int32

How many fields a struct may declare before a message is refused.

Five hundred and twelve is the Rust crate's max_type_fields. The count is written by the message and read before the fields are, so it is the cheapest place to stop a message that claims more fields than it has.

graph : Int32

How many bytes of variable-length payload one message may declare before it is refused: strings, binaries, dense arrays and container bodies added up as they are read.

A hundred and twenty-eight mebibytes is the Rust crate's max_graph_memory_bytes. Declared lengths are already bounded by the bytes actually present, so this gate is the one that bounds a message made of many small declarations whose total is a large allocation.

Methods

new

fn Config::new(xlang? : Bool, track_ref? : Bool, check_string? : Bool, depth? : Int32, fields? : Int32, graph? : Int32) -> Self

The same preset, one argument at a time.

For when several parts differ at once and a record update would mean spelling the ones that did not change.

Generated from src/pkg.generated.mbti and the doc comments beside this declaration.