mix<Owner extends Object, Value extends Object, PropValue extends Object> static method

MixProtocolFieldCodec<Owner, Prop<PropValue>> mix<Owner extends Object, Value extends Object, PropValue extends Object>({
  1. required String wire,
  2. required MixProtocolValueCodec<Value> codec,
  3. required Prop<PropValue>? read(
    1. Owner value
    ),
  4. String? fieldName,
  5. String? inventoryName,
})

Creates a property field whose sources are Mix values.

Implementation

static MixProtocolFieldCodec<Owner, Prop<PropValue>>
mix<Owner extends Object, Value extends Object, PropValue extends Object>({
  required String wire,
  required MixProtocolValueCodec<Value> codec,
  required Prop<PropValue>? Function(Owner value) read,
  String? fieldName,
  String? inventoryName,
}) {
  final fieldNameOrWire = fieldName ?? wire;
  final customCodec = codec._mixPropCodec?.call(fieldNameOrWire);
  if (customCodec != null) {
    return MixProtocolFieldCodec._(
      SchemaField<Owner, Prop<PropValue>>(
        wire: wire,
        codec: customCodec as AckSchema<Object, Prop<PropValue>>,
        inventoryName: inventoryName,
        schemaSemantics: codec._fieldSemantics,
        read: read,
      ),
    );
  }

  return MixProtocolFieldCodec._(
    propMixField<Owner, Value, PropValue>(
      wire,
      codec._schema,
      read,
      fieldName: fieldName,
      inventoryName: inventoryName,
      schemaSemantics: codec._fieldSemantics,
      convertValue: (value) => codec._convertValue?.call(value),
    ),
  );
}