Skip to main content

Module codec

Module codec 

Source
Expand description

What the codec that constructo codegen generates calls and needs no trait for: the error of reading or writing a value, the setting of how names are written, the parts of a record and a tuple in the order of their declaration, the numbers, and the builders of a tree.

The traits and the tables of names and consts are generated with each codec, in the program’s own crate, so that they can be implemented for a type of any crate. What is here is the same for every codec. Its messages are those of constructo check, where the error is one that check finds.

Structs§

Error
An error of reading or of writing a value.

Enums§

Names
How a codec writes the name of a constructor.
NoDefault
Why a type has no default that can be used where an argument is left out.
Step
A step of the path from the value that was read or written to the value that an error is about.

Functions§

arguments
The arguments of a constructor with a tuple, in the order of its parameters, which are given by their names, or None for a parameter that has none. The arguments without a name bind the parameters in order, and those with a name bind the parameter of that name, which may be one that could have been bound in order. A named parameter that is not bound is None, and takes the default of its type; an unnamed one is an error. The errors are check’s, in its order.
array
An array.
enter
The depth of a value inside one at depth, which is an error if it is more than max. Each value is a level, a scalar included, as the parser counts them, so a value that is read is never deeper than one that the parser reads, and one that is written can be read back.
expected
The error for a value that is not of the type that is expected: Expected Nat but found String.
fields
The members of a record, or of a constructor with a record, in the order of names, which are the fields. Every field is required and no other is allowed, and the errors are check’s, in its order: a duplicate or an unknown field at the member, then a missing one at the record. owner is the constructor, or record for a record without a name.
float
A Float, as the shortest text that reads back as the same f64. Rust’s own shortest text is used, with .0 put in where it has no point, as in 1.0e300, and a zero is written as 0.0, since there is no negative zero. A value that is not finite has no text yet, and is an error.
found
What a value is, for a message, as check says it: Nat, Int, Float, String, an array or a record. A tagged value is its name as it is written, which a codec can give with its type.
int
An Int, with its sign, which a number that is not negative has as +, as convert writes it.
is_const_name
Whether a name is that of a const, which starts with a lower-case letter or _, after any qualifier, as a constructor starts with a capital letter (decision 35).
nat
A Nat.
no_default
The error for an argument that is left out, at the constructor, where its type has no default that can be used. The messages are check’s, with the codec’s limit, and param is the name of the parameter.
parse
The values of a text.
parse_one
The one value of a text, which is an error at the start of the text if it has more or fewer.
read_float
A Float from its text, or from that of a Nat or an Int if widening is set: the nearest f64, which is the one loss that a mapping is allowed. A number too small to be held other than as zero is zero, and one too large for an f64, such as 1.0e400, is an error at it, since making it infinite would change a finite value into one that is not. There is no negative zero, so -0.0 is 0.0.
read_int
An Int from its text, or from that of a Nat if widening is set. A number that is too large for an i64 is an error at it.
read_nat
A Nat from its text. A sign makes a number an Int, which is never a Nat, as in check, and a number that is too large for a u64 is an error at it.
read_string
A string from its value.
record
A record without a name, with its members in the order given.
spend
Counts a node of a default against what is left of the limit.
string
A String.
tagged_array
A constructor with an array.
tagged_record
A constructor with a record.
tagged_tuple
A constructor with a tuple, each argument with its name if it is written by name.
unit
A constructor with no body, or a reference to a const.
write_text
The text of the values, each ended by ; and a new line, as convert writes them.