Skip to content

Add a unified interface implementation for the dart class of the signal generated by rinf gen #602

@nsfoxer

Description

@nsfoxer

Current Status

In the generated classes now, there is a Uint8List bincodeserialize() method, and we hope to have a unified interface.

@immutable
// no mixin
class AddSyncDirMsg {
  const AddSyncDirMsg({
    required this.localDir,
    required this.tag,
  });
  Uint8List bincodeSerialize() {
      final serializer = BincodeSerializer();
      serialize(serializer);
      return serializer.bytes;
  }
//.....

Describe the Task

mixin:

// 定义一个 mixin 来约束 bincodeSerialize 方法
mixin ApiSerializable {
  Uint8List bincodeSerialize();
}

generate file:

@immutable
// having a mixin
class AddSyncDirMsg  with ApiSerializable {
  const AddSyncDirMsg({
    required this.localDir,
    required this.tag,
  });
  Uint8List bincodeSerialize() {
      final serializer = BincodeSerializer();
      serialize(serializer);
      return serializer.bytes;
  }
//.....

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementIncludes new improvements

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions