diff --git a/features/unmarshal/unmarshal.go b/features/unmarshal/unmarshal.go index 294dbe1..0f7bce0 100644 --- a/features/unmarshal/unmarshal.go +++ b/features/unmarshal/unmarshal.go @@ -158,10 +158,7 @@ func (p *unmarshal) declareMapField(varName string, nullable bool, field *protog } func (p *unmarshal) mapField(varName string, field *protogen.Field) { - var unique bool - if _, ok := proto.GetExtension(field.Desc.Options(), vtproto.E_Unique).(bool); ok { - unique = true - } + unique := proto.GetExtension(field.Desc.Options(), vtproto.E_Options).(*vtproto.Opts).GetUnique() switch field.Desc.Kind() { case protoreflect.DoubleKind: @@ -211,7 +208,7 @@ func (p *unmarshal) mapField(varName string, field *protogen.Field) { p.P(`if intStringLen`, varName, ` == 0 {`) p.P(varName, ` = ""`) p.P(`} else {`) - p.P(varName, ` = unique.Make[string](`, p.Ident("unsafe", `String`), `(&dAtA[iNdEx], intStringLen`, varName, `)).Value()`) + p.P(varName, ` = `, p.Ident("unique", `Make`), `[string](`, p.Ident("unsafe", `String`), `(&dAtA[iNdEx], intStringLen`, varName, `)).Value()`) p.P(`}`) default: p.P(varName, ` = `, "string", `(dAtA[iNdEx:postStringIndex`, varName, `])`) @@ -289,17 +286,11 @@ func (p *unmarshal) noStarOrSliceType(field *protogen.Field) string { } func (p *unmarshal) fieldItem(field *protogen.Field, fieldname string, message *protogen.Message, proto3 bool) { - var unique bool - repeated := field.Desc.Cardinality() == protoreflect.Repeated typ := p.noStarOrSliceType(field) oneof := field.Oneof != nil && !field.Oneof.Desc.IsSynthetic() nullable := field.Oneof != nil && field.Oneof.Desc.IsSynthetic() - if _, ok := proto.GetExtension(field.Desc.Options(), vtproto.E_Unique).(bool); ok { - unique = true - } - switch field.Desc.Kind() { case protoreflect.DoubleKind: p.P(`var v uint64`) @@ -429,6 +420,8 @@ func (p *unmarshal) fieldItem(field *protogen.Field, fieldname string, message * p.P(`m.`, fieldname, ` = &b`) } case protoreflect.StringKind: + unique := proto.GetExtension(field.Desc.Options(), vtproto.E_Options).(*vtproto.Opts).GetUnique() + p.P(`var stringLen uint64`) p.decodeVarint("stringLen", "uint64") p.P(`intStringLen := int(stringLen)`) @@ -454,7 +447,7 @@ func (p *unmarshal) fieldItem(field *protogen.Field, fieldname string, message * str = "stringValue" p.P(`var stringValue string`) p.P(`if intStringLen > 0 {`) - p.P(`stringValue = unique.Make[string](`, p.Ident("unsafe", `String`), `(&dAtA[iNdEx], intStringLen)).Value()`) + p.P(`stringValue = `, p.Ident("unique", `Make`), `[string](`, p.Ident("unsafe", `String`), `(&dAtA[iNdEx], intStringLen)).Value()`) p.P(`}`) } if oneof { diff --git a/include/github.com/planetscale/vtprotobuf/vtproto/ext.proto b/include/github.com/planetscale/vtprotobuf/vtproto/ext.proto index 5878452..00c117c 100644 --- a/include/github.com/planetscale/vtprotobuf/vtproto/ext.proto +++ b/include/github.com/planetscale/vtprotobuf/vtproto/ext.proto @@ -12,11 +12,11 @@ extend google.protobuf.MessageOptions { } extend google.protobuf.FieldOptions { - optional FieldOptions options = 64102; + optional Opts options = 999999; } // These options should be used during schema definition, // applying them to some of the fields in protobuf -message FieldOptions { +message Opts { optional bool unique = 1; } \ No newline at end of file diff --git a/testproto/unique/unique.pb.go b/testproto/unique/unique.pb.go new file mode 100644 index 0000000..cc1fb68 --- /dev/null +++ b/testproto/unique/unique.pb.go @@ -0,0 +1,147 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v3.21.12 +// source: unique/unique.proto + +package unique + +import ( + _ "github.com/planetscale/vtprotobuf/vtproto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type UniqueFieldExtension struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Foo string `protobuf:"bytes,1,opt,name=foo,proto3" json:"foo,omitempty"` +} + +func (x *UniqueFieldExtension) Reset() { + *x = UniqueFieldExtension{} + if protoimpl.UnsafeEnabled { + mi := &file_unique_unique_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UniqueFieldExtension) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UniqueFieldExtension) ProtoMessage() {} + +func (x *UniqueFieldExtension) ProtoReflect() protoreflect.Message { + mi := &file_unique_unique_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UniqueFieldExtension.ProtoReflect.Descriptor instead. +func (*UniqueFieldExtension) Descriptor() ([]byte, []int) { + return file_unique_unique_proto_rawDescGZIP(), []int{0} +} + +func (x *UniqueFieldExtension) GetFoo() string { + if x != nil { + return x.Foo + } + return "" +} + +var File_unique_unique_proto protoreflect.FileDescriptor + +var file_unique_unique_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x2f, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x74, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2f, 0x76, 0x74, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2f, 0x65, 0x78, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x31, 0x0a, 0x14, 0x55, 0x6e, + 0x69, 0x71, 0x75, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x19, 0x0a, 0x03, 0x66, 0x6f, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, + 0x07, 0xfa, 0xa3, 0xe8, 0x03, 0x02, 0x08, 0x01, 0x52, 0x03, 0x66, 0x6f, 0x6f, 0x42, 0x12, 0x5a, + 0x10, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x75, 0x6e, 0x69, 0x71, 0x75, + 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_unique_unique_proto_rawDescOnce sync.Once + file_unique_unique_proto_rawDescData = file_unique_unique_proto_rawDesc +) + +func file_unique_unique_proto_rawDescGZIP() []byte { + file_unique_unique_proto_rawDescOnce.Do(func() { + file_unique_unique_proto_rawDescData = protoimpl.X.CompressGZIP(file_unique_unique_proto_rawDescData) + }) + return file_unique_unique_proto_rawDescData +} + +var file_unique_unique_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_unique_unique_proto_goTypes = []interface{}{ + (*UniqueFieldExtension)(nil), // 0: UniqueFieldExtension +} +var file_unique_unique_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_unique_unique_proto_init() } +func file_unique_unique_proto_init() { + if File_unique_unique_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_unique_unique_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UniqueFieldExtension); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_unique_unique_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_unique_unique_proto_goTypes, + DependencyIndexes: file_unique_unique_proto_depIdxs, + MessageInfos: file_unique_unique_proto_msgTypes, + }.Build() + File_unique_unique_proto = out.File + file_unique_unique_proto_rawDesc = nil + file_unique_unique_proto_goTypes = nil + file_unique_unique_proto_depIdxs = nil +} diff --git a/testproto/unique/unique.proto b/testproto/unique/unique.proto new file mode 100644 index 0000000..767023b --- /dev/null +++ b/testproto/unique/unique.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; +option go_package = "testproto/unique"; + +import "github.com/planetscale/vtprotobuf/vtproto/ext.proto"; + +message UniqueFieldExtension { + string foo = 1 [(vtproto.options).unique = true]; +} diff --git a/testproto/unique/unique_test.go b/testproto/unique/unique_test.go new file mode 100644 index 0000000..bef4055 --- /dev/null +++ b/testproto/unique/unique_test.go @@ -0,0 +1,25 @@ +package unique + +import ( + "testing" + "unsafe" + + "github.com/stretchr/testify/require" +) + +func TestUnmarshalSameMemory(t *testing.T) { + m := &UniqueFieldExtension{ + Foo: "bar", + } + + b, err := m.MarshalVTStrict() + require.NoError(t, err) + + m2 := &UniqueFieldExtension{} + require.NoError(t, m2.UnmarshalVT(b)) + + m3 := &UniqueFieldExtension{} + require.NoError(t, m3.UnmarshalVT(b)) + + require.Equal(t, unsafe.StringData(m2.Foo), unsafe.StringData(m3.Foo)) +} diff --git a/testproto/unique/unique_vtproto.pb.go b/testproto/unique/unique_vtproto.pb.go new file mode 100644 index 0000000..d232bc8 --- /dev/null +++ b/testproto/unique/unique_vtproto.pb.go @@ -0,0 +1,327 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: (devel) +// source: unique/unique.proto + +package unique + +import ( + fmt "fmt" + protohelpers "github.com/planetscale/vtprotobuf/protohelpers" + proto "google.golang.org/protobuf/proto" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + unique "unique" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +func (m *UniqueFieldExtension) CloneVT() *UniqueFieldExtension { + if m == nil { + return (*UniqueFieldExtension)(nil) + } + r := new(UniqueFieldExtension) + r.Foo = m.Foo + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *UniqueFieldExtension) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (this *UniqueFieldExtension) EqualVT(that *UniqueFieldExtension) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Foo != that.Foo { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *UniqueFieldExtension) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*UniqueFieldExtension) + if !ok { + return false + } + return this.EqualVT(that) +} +func (m *UniqueFieldExtension) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UniqueFieldExtension) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *UniqueFieldExtension) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Foo) > 0 { + i -= len(m.Foo) + copy(dAtA[i:], m.Foo) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Foo))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *UniqueFieldExtension) MarshalVTStrict() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UniqueFieldExtension) MarshalToVTStrict(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVTStrict(dAtA[:size]) +} + +func (m *UniqueFieldExtension) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Foo) > 0 { + i -= len(m.Foo) + copy(dAtA[i:], m.Foo) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Foo))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *UniqueFieldExtension) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Foo) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *UniqueFieldExtension) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UniqueFieldExtension: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UniqueFieldExtension: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Foo", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var stringValue string + if intStringLen > 0 { + stringValue = unique.Make[string](unsafe.String(&dAtA[iNdEx], intStringLen)).Value() + } + m.Foo = stringValue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UniqueFieldExtension) UnmarshalVTUnsafe(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UniqueFieldExtension: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UniqueFieldExtension: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Foo", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var stringValue string + if intStringLen > 0 { + stringValue = unsafe.String(&dAtA[iNdEx], intStringLen) + } + m.Foo = stringValue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} diff --git a/vtproto/ext.pb.go b/vtproto/ext.pb.go index dd05f4b..1b1908d 100644 --- a/vtproto/ext.pb.go +++ b/vtproto/ext.pb.go @@ -11,6 +11,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" descriptorpb "google.golang.org/protobuf/types/descriptorpb" reflect "reflect" + sync "sync" ) const ( @@ -20,6 +21,55 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// These options should be used during schema definition, +// applying them to some of the fields in protobuf +type Opts struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Unique *bool `protobuf:"varint,1,opt,name=unique" json:"unique,omitempty"` +} + +func (x *Opts) Reset() { + *x = Opts{} + if protoimpl.UnsafeEnabled { + mi := &file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Opts) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Opts) ProtoMessage() {} + +func (x *Opts) ProtoReflect() protoreflect.Message { + mi := &file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Opts.ProtoReflect.Descriptor instead. +func (*Opts) Descriptor() ([]byte, []int) { + return file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_rawDescGZIP(), []int{0} +} + +func (x *Opts) GetUnique() bool { + if x != nil && x.Unique != nil { + return *x.Unique + } + return false +} + var file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_extTypes = []protoimpl.ExtensionInfo{ { ExtendedType: (*descriptorpb.MessageOptions)(nil), @@ -31,10 +81,10 @@ var file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_extTypes = []protoi }, { ExtendedType: (*descriptorpb.FieldOptions)(nil), - ExtensionType: (*bool)(nil), - Field: 64102, - Name: "vtproto.unique", - Tag: "varint,64102,opt,name=unique", + ExtensionType: (*Opts)(nil), + Field: 999999, + Name: "vtproto.options", + Tag: "bytes,999999,opt,name=options", Filename: "github.com/planetscale/vtprotobuf/vtproto/ext.proto", }, } @@ -47,8 +97,8 @@ var ( // Extension fields to descriptorpb.FieldOptions. var ( - // optional bool unique = 64102; - E_Unique = &file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_extTypes[1] + // optional vtproto.Opts options = 999999; + E_Options = &file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_extTypes[1] ) var File_github_com_planetscale_vtprotobuf_vtproto_ext_proto protoreflect.FileDescriptor @@ -60,31 +110,49 @@ var file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_rawDesc = []byte{ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x76, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0x1e, 0x0a, 0x04, 0x4f, 0x70, 0x74, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x6e, 0x69, 0x71, + 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x3a, 0x3b, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x70, 0x6f, 0x6f, 0x6c, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xe5, 0xf4, 0x03, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x70, 0x6f, 0x6f, 0x6c, 0x3a, 0x37, 0x0a, - 0x06, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xe6, 0xf4, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, - 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x42, 0x49, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x42, 0x07, 0x56, - 0x54, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x74, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2f, 0x76, - 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x74, 0x70, 0x72, 0x6f, 0x74, - 0x6f, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x70, 0x6f, 0x6f, 0x6c, 0x3a, 0x48, 0x0a, + 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, + 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xbf, 0x84, 0x3d, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0d, 0x2e, 0x76, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4f, 0x70, 0x74, 0x73, 0x52, 0x07, + 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x49, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x42, 0x07, + 0x56, 0x54, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x74, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x2f, + 0x76, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x74, 0x70, 0x72, 0x6f, + 0x74, 0x6f, } +var ( + file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_rawDescOnce sync.Once + file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_rawDescData = file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_rawDesc +) + +func file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_rawDescGZIP() []byte { + file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_rawDescOnce.Do(func() { + file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_rawDescData = protoimpl.X.CompressGZIP(file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_rawDescData) + }) + return file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_rawDescData +} + +var file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_goTypes = []interface{}{ - (*descriptorpb.MessageOptions)(nil), // 0: google.protobuf.MessageOptions - (*descriptorpb.FieldOptions)(nil), // 1: google.protobuf.FieldOptions + (*Opts)(nil), // 0: vtproto.Opts + (*descriptorpb.MessageOptions)(nil), // 1: google.protobuf.MessageOptions + (*descriptorpb.FieldOptions)(nil), // 2: google.protobuf.FieldOptions } var file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_depIdxs = []int32{ - 0, // 0: vtproto.mempool:extendee -> google.protobuf.MessageOptions - 1, // 1: vtproto.unique:extendee -> google.protobuf.FieldOptions - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name + 1, // 0: vtproto.mempool:extendee -> google.protobuf.MessageOptions + 2, // 1: vtproto.options:extendee -> google.protobuf.FieldOptions + 0, // 2: vtproto.options:type_name -> vtproto.Opts + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 2, // [2:3] is the sub-list for extension type_name 0, // [0:2] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } @@ -94,18 +162,33 @@ func file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_init() { if File_github_com_planetscale_vtprotobuf_vtproto_ext_proto != nil { return } + if !protoimpl.UnsafeEnabled { + file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Opts); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_rawDesc, NumEnums: 0, - NumMessages: 0, + NumMessages: 1, NumExtensions: 2, NumServices: 0, }, GoTypes: file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_goTypes, DependencyIndexes: file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_depIdxs, + MessageInfos: file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_msgTypes, ExtensionInfos: file_github_com_planetscale_vtprotobuf_vtproto_ext_proto_extTypes, }.Build() File_github_com_planetscale_vtprotobuf_vtproto_ext_proto = out.File