GeneralFieldsSerializer
This class provides functionality for serializing general fields within a schema, managing both standard and computed fields. It utilizes a mapping of field names to serializers and incorporates filtering logic to determine which fields are included in the output. Additionally, the class supports handling extra fields through an optional combined serializer and tracks required field counts for validation during the serialization process.
Attributes
| Attribute | Type | Description |
|---|---|---|
| fields | AHashMap< PyBackedStr, SerField > | A mapping of field names to their respective serialization logic and configurations. |
| computed_fields | Option< ComputedFields > | Optional configuration for fields that are calculated dynamically during serialization rather than stored directly. |
| mode | [FieldsMode](fieldsmode.md?sid=serializers_fields_fieldsmode) | The operational mode determining how fields are processed and validated during the serialization cycle. |
| extra_serializer | Option< Arc< CombinedSerializer > > | An optional reference to a combined serializer used to handle additional data not defined in the primary fields. |
| filter | SchemaFilter< isize > | A schema filter used to include or exclude specific fields based on their hash values. |
| required_fields | usize | The total count of fields that must be present for a successful serialization pass. |
Constructor
Signature
def GeneralFieldsSerializer(
fields: AHashMap< PyBackedStr, SerField >,
computed_fields: Option< ComputedFields >,
mode: [FieldsMode](fieldsmode.md?sid=serializers_fields_fieldsmode),
extra_serializer: Option< Arc< CombinedSerializer > >,
filter: SchemaFilter< isize >,
required_fields: usize
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| fields | AHashMap< PyBackedStr, SerField > | A map of field names to their respective serializer configurations. |
| computed_fields | Option< ComputedFields > | Optional configuration for fields that are computed at runtime. |
| mode | [FieldsMode](fieldsmode.md?sid=serializers_fields_fieldsmode) | The mode determining how fields are processed during serialization. |
| extra_serializer | Option< Arc< CombinedSerializer > > | An optional serializer for handling extra data not defined in the primary fields. |
| filter | SchemaFilter< isize > | A filter used to include or exclude specific fields based on their hash values. |
| required_fields | usize | The count of fields that are mandatory for serialization. |
Signature
def new(
fields: AHashMap< PyBackedStr, SerField >,
computed_fields: Option< ComputedFields >,
mode: [FieldsMode](fieldsmode.md?sid=serializers_fields_fieldsmode),
extra_serializer: Option< Arc< CombinedSerializer > >,
filter: SchemaFilter< isize >,
required_fields: usize
) - > [GeneralFieldsSerializer](generalfieldsserializer.md?sid=serializers_fields_generalfieldsserializer)
Parameters
| Name | Type | Description |
|---|---|---|
| fields | AHashMap< PyBackedStr, SerField > | A mapping of field names to their respective serialization logic and configuration. |
| computed_fields | Option< ComputedFields > | Optional collection of properties decorated with @computed_field to be included in the output. |
| mode | [FieldsMode](fieldsmode.md?sid=serializers_fields_fieldsmode) | The operational mode determining how fields are accessed and validated during serialization. |
| extra_serializer | Option< Arc< CombinedSerializer > > | An optional serializer used to handle extra attributes or catch-all fields not explicitly defined. |
| filter | SchemaFilter< isize > | A filter used to include or exclude specific fields based on their hashed identifiers. |
| required_fields | usize | The count of fields that must be present for a successful serialization pass. |