// Code generated by gotdgen, DO NOT EDIT. package tdapi 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{} ) // ChatFolderIcon represents TL type `chatFolderIcon#f74aa0e6`. type ChatFolderIcon struct { // The chosen icon name for short folder representation; one of "All", "Unread", // "Unmuted", "Bots", "Channels", "Groups", "Private", "Custom", "Setup", "Cat", "Crown", Name string } // ChatFolderIconTypeID is TL type id of ChatFolderIcon. const ChatFolderIconTypeID = 0xf74aa0e6 // Ensuring interfaces in compile-time for ChatFolderIcon. var ( _ bin.Encoder = &ChatFolderIcon{} _ bin.Decoder = &ChatFolderIcon{} _ bin.BareEncoder = &ChatFolderIcon{} _ bin.BareDecoder = &ChatFolderIcon{} ) func (c *ChatFolderIcon) Zero() bool { if c == nil { return true } if !(c.Name == "") { return false } return true } // String implements fmt.Stringer. func (c *ChatFolderIcon) String() string { if c == nil { return "ChatFolderIcon(nil)" } type Alias ChatFolderIcon return fmt.Sprintf("ChatFolderIcon%+v", Alias(*c)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*ChatFolderIcon) TypeID() uint32 { return ChatFolderIconTypeID } // TypeName returns name of type in TL schema. func (*ChatFolderIcon) TypeName() string { return "chatFolderIcon" } // TypeInfo returns info about TL type. func (c *ChatFolderIcon) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "chatFolderIcon", ID: ChatFolderIconTypeID, } if c == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "Name", SchemaName: "name", }, } return typ } // Encode implements bin.Encoder. func (c *ChatFolderIcon) Encode(b *bin.Buffer) error { if c == nil { return fmt.Errorf("can't encode chatFolderIcon#f74aa0e6 as nil") } b.PutID(ChatFolderIconTypeID) return c.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (c *ChatFolderIcon) EncodeBare(b *bin.Buffer) error { if c == nil { return fmt.Errorf("can't encode chatFolderIcon#f74aa0e6 as nil") } b.PutString(c.Name) return nil } // Decode implements bin.Decoder. func (c *ChatFolderIcon) Decode(b *bin.Buffer) error { if c == nil { return fmt.Errorf("can't decode chatFolderIcon#f74aa0e6 to nil") } if err := b.ConsumeID(ChatFolderIconTypeID); err != nil { return fmt.Errorf("unable to decode chatFolderIcon#f74aa0e6: %w", err) } return c.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (c *ChatFolderIcon) DecodeBare(b *bin.Buffer) error { if c == nil { return fmt.Errorf("can't decode chatFolderIcon#f74aa0e6 to nil") } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode chatFolderIcon#f74aa0e6: field name: %w", err) } c.Name = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (c *ChatFolderIcon) EncodeTDLibJSON(b tdjson.Encoder) error { if c == nil { return fmt.Errorf("can't encode chatFolderIcon#f74aa0e6 as nil") } b.ObjStart() b.PutID("chatFolderIcon") b.Comma() b.FieldStart("name") b.PutString(c.Name) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (c *ChatFolderIcon) DecodeTDLibJSON(b tdjson.Decoder) error { if c == nil { return fmt.Errorf("can't decode chatFolderIcon#f74aa0e6 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("chatFolderIcon"); err != nil { return fmt.Errorf("unable to decode chatFolderIcon#f74aa0e6: %w", err) } case "name": value, err := b.String() if err != nil { return fmt.Errorf("unable to decode chatFolderIcon#f74aa0e6: field name: %w", err) } c.Name = value default: return b.Skip() } return nil }) } // GetName returns value of Name field. func (c *ChatFolderIcon) GetName() (value string) { if c == nil { return } return c.Name }