JsonLimits structv0.1.0

Source
What a caller will accept from a document.
pub struct JsonLimits {
    pub maximumBytes: uint;
    pub maximumTextBytes: uint;
    pub maximumDepth: uint;
    pub maximumEntries: uint;
}

Every field is a refusal a caller might need to make against untrusted input, and every default is generous enough for ordinary documents and far short of what exhausts a machine.

Fields

NameTypeDescription
maximumBytesuintThe longest document, in bytes.
maximumTextBytesuintThe longest single string, in bytes.
maximumDepthuintHow deeply containers may nest. This is the one that protects a recursive parser's stack.
maximumEntriesuintHow many elements or members one container may hold.

Associated functions

Default

pub func Default() -> JsonLimits

Limits generous enough for ordinary documents: sixty-four mebibytes, sixteen mebibyte strings, a hundred and twenty-eight levels of nesting, and a million entries per container.

Returns: the limits an ordinary parse uses

Source

Unlimited

pub func Unlimited() -> JsonLimits

No limits at all, for input that is already trusted. Named so that choosing it is visible: a document read from the network should never use this, and a reviewer should be able to find every place that did.

Returns: limits that refuse nothing, for input that is already trusted

Source