// Code generated by gotdgen, DO NOT EDIT. package td import ( "context" "errors" "fmt" "sort" "strings" "go.uber.org/multierr" "go.mau.fi/mautrix-telegram/pkg/gotd/bin" "go.mau.fi/mautrix-telegram/pkg/gotd/tdjson" "go.mau.fi/mautrix-telegram/pkg/gotd/tdp" "go.mau.fi/mautrix-telegram/pkg/gotd/tgerr" ) // No-op definition for keeping imports. var ( _ = bin.Buffer{} _ = context.Background() _ = fmt.Stringer(nil) _ = strings.Builder{} _ = errors.Is _ = multierr.AppendInto _ = sort.Ints _ = tdp.Format _ = tgerr.Error{} _ = tdjson.Encoder{} ) // TestBytes represents TL type `testBytes#a422c4de`. // // See https://localhost:80/doc/constructor/testBytes for reference. type TestBytes struct { // Bytes Value []byte } // TestBytesTypeID is TL type id of TestBytes. const TestBytesTypeID = 0xa422c4de // Ensuring interfaces in compile-time for TestBytes. var ( _ bin.Encoder = &TestBytes{} _ bin.Decoder = &TestBytes{} _ bin.BareEncoder = &TestBytes{} _ bin.BareDecoder = &TestBytes{} ) func (t *TestBytes) Zero() bool { if t == nil { return true } if !(t.Value == nil) { return false } return true } // String implements fmt.Stringer. func (t *TestBytes) String() string { if t == nil { return "TestBytes(nil)" } type Alias TestBytes return fmt.Sprintf("TestBytes%+v", Alias(*t)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*TestBytes) TypeID() uint32 { return TestBytesTypeID } // TypeName returns name of type in TL schema. func (*TestBytes) TypeName() string { return "testBytes" } // TypeInfo returns info about TL type. func (t *TestBytes) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "testBytes", ID: TestBytesTypeID, } if t == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "Value", SchemaName: "value", }, } return typ } // Encode implements bin.Encoder. func (t *TestBytes) Encode(b *bin.Buffer) error { if t == nil { return fmt.Errorf("can't encode testBytes#a422c4de as nil") } b.PutID(TestBytesTypeID) return t.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (t *TestBytes) EncodeBare(b *bin.Buffer) error { if t == nil { return fmt.Errorf("can't encode testBytes#a422c4de as nil") } b.PutBytes(t.Value) return nil } // Decode implements bin.Decoder. func (t *TestBytes) Decode(b *bin.Buffer) error { if t == nil { return fmt.Errorf("can't decode testBytes#a422c4de to nil") } if err := b.ConsumeID(TestBytesTypeID); err != nil { return fmt.Errorf("unable to decode testBytes#a422c4de: %w", err) } return t.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (t *TestBytes) DecodeBare(b *bin.Buffer) error { if t == nil { return fmt.Errorf("can't decode testBytes#a422c4de to nil") } { value, err := b.Bytes() if err != nil { return fmt.Errorf("unable to decode testBytes#a422c4de: field value: %w", err) } t.Value = value } return nil } // GetValue returns value of Value field. func (t *TestBytes) GetValue() (value []byte) { if t == nil { return } return t.Value }