package meta func Read(reader Reader, createById MetaFactory) (v IMetaStruct, err error) { return ReadStructGeneric(reader, createById, "") } func Write(writer Writer, m IMetaStruct) error { return WriteStructGeneric(writer, m, "") } func ReadStructGeneric(reader Reader, createById MetaFactory, field string) (v IMetaStruct, err error) { if err = reader.BeginContainer(field); err != nil { return } var classId uint32 if err = reader.ReadU32(&classId, ""); err != nil { return } if v, err = createById(classId); err != nil { return } if err = v.ReadFields(reader); err != nil { return } err = reader.EndContainer() return } func WriteStructGeneric(writer Writer, m IMetaStruct, field string) error { writer.BeginContainer(field) if err := writer.WriteU32(m.CLASS_ID(), ""); err != nil { return err } if err := m.WriteFields(writer); err != nil { return err } return writer.EndContainer() } func ReadStruct(reader Reader, m IMetaStruct, field string) error { err := reader.BeginContainer(field) if err != nil { return err } err = m.ReadFields(reader) if err != nil { return err } return reader.EndContainer() } func WriteStruct(writer Writer, m IMetaStruct, field string) error { writer.BeginContainer(field) err := m.WriteFields(writer) if err != nil { return err } return writer.EndContainer() } func IsRPCFailed(rpc IRPC) bool { code, _ := rpc.GetError() return code != 0 }