Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Unreleased
Added
- Support for variable-length arrays via bare
tuple[T, ...]fields, which read all remaining bytes in the buffer (must be the last field in a struct). (#11) CCountedByannotation for variadic tuple fields whose element count is stored in another field. SupportsCCountedBy.name(field_name)for a static count field name andCCountedBy.template("{}_count")for a name derived from the array field name. (#11)CountedArray[T]convenience type alias fortuple[T, ...]annotated withCCountedBy.template("{}_count"), expecting a preceding{field_name}_countfield. (#11)SizeRangeenum (FIXED,BOUNDED,UNBOUNDED) to classify whether a field has a fixed, bounded-variable, or unbounded-variable size. (#11)CBuildContextTypedDict providing endianness, size type, field name, and struct schema to functions that build C schemas at class-definition time. (#11)CArraySchemaandCArrayCountSchemainternal schema types for representing C arrays. (#11)- Support for Pydantic
function-after,function-before, andfunction-wrapvalidator schemas, which are now transparently handled during schema construction. (#11)
Changed
CEncoded.get_encodernow receives a singleCBuildContextdict instead of separateendian_typeandsize_typepositional arguments. (#11)CEncoderSchemanow requires asize_range: SizeRangefield. (#11)CStructFieldSchema.variable_length: boolhas been replaced bysize_range: SizeRange. (#11)
v0.6.0
Added
get_c_format_prefixutility as a public function. (#10)
Changed
CEncoderSchemapack and unpack functions now accept a context arg. In particular,unpacknow receives aCUnpackContextthat includes apreceding_fieldsdict for reading previously unpacked fields from the same struct. (#10)
v0.5.0
Added
- Support for fields with default values. (#9)
- Built-in types
LongLong,UnsignedLongLong,SSizeT, andSizeT(format charsq,Q,n,N). (#9) - Tagged union schemas can now mix variable-length and fixed-length variants. (#9)
v0.4.0
Added
CEncodedannotation for fields that need custom or variable-length binary encoding not expressible as astructformat string. (#8)RawBytestype for trailing variable-length byte fields. (#8)
Changed
- Internal schema representation changed from
CFormatSchematoCEncoderSchema.CFormatfields are now converted toCEncoderSchemainternally. (#8)
Fixed
- Inter-field padding now aligns based on the next field's natural alignment instead of only the struct's overall alignment. (#8)
v0.3.0
Changed
- Byte order and data type sizes are now set at class definition time with
c_endian_typeandc_size_type, instead of being passed as arguments toc_packandc_unpack. This means the binary layout of a model is fully determined by its class definition, not by arguments passed at pack or unpack time. (#6)
v0.2.0
Added
- Support for Pydantic tagged unions. (#5)
v0.1.0
Added
CModelbase class.CFormatfor custom field formats.- Built-in field types in
cmodel.types. - Guides and documentation.