// Code generated by gotdgen, DO NOT EDIT. package mt 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{} ) // HTTPWaitRequest represents TL type `http_wait#9299359f`. type HTTPWaitRequest struct { // MaxDelay field of HTTPWaitRequest. MaxDelay int // WaitAfter field of HTTPWaitRequest. WaitAfter int // MaxWait field of HTTPWaitRequest. MaxWait int } // HTTPWaitRequestTypeID is TL type id of HTTPWaitRequest. const HTTPWaitRequestTypeID = 0x9299359f // Ensuring interfaces in compile-time for HTTPWaitRequest. var ( _ bin.Encoder = &HTTPWaitRequest{} _ bin.Decoder = &HTTPWaitRequest{} _ bin.BareEncoder = &HTTPWaitRequest{} _ bin.BareDecoder = &HTTPWaitRequest{} ) func (h *HTTPWaitRequest) Zero() bool { if h == nil { return true } if !(h.MaxDelay == 0) { return false } if !(h.WaitAfter == 0) { return false } if !(h.MaxWait == 0) { return false } return true } // String implements fmt.Stringer. func (h *HTTPWaitRequest) String() string { if h == nil { return "HTTPWaitRequest(nil)" } type Alias HTTPWaitRequest return fmt.Sprintf("HTTPWaitRequest%+v", Alias(*h)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*HTTPWaitRequest) TypeID() uint32 { return HTTPWaitRequestTypeID } // TypeName returns name of type in TL schema. func (*HTTPWaitRequest) TypeName() string { return "http_wait" } // TypeInfo returns info about TL type. func (h *HTTPWaitRequest) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "http_wait", ID: HTTPWaitRequestTypeID, } if h == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "MaxDelay", SchemaName: "max_delay", }, { Name: "WaitAfter", SchemaName: "wait_after", }, { Name: "MaxWait", SchemaName: "max_wait", }, } return typ } // Encode implements bin.Encoder. func (h *HTTPWaitRequest) Encode(b *bin.Buffer) error { if h == nil { return fmt.Errorf("can't encode http_wait#9299359f as nil") } b.PutID(HTTPWaitRequestTypeID) return h.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (h *HTTPWaitRequest) EncodeBare(b *bin.Buffer) error { if h == nil { return fmt.Errorf("can't encode http_wait#9299359f as nil") } b.PutInt(h.MaxDelay) b.PutInt(h.WaitAfter) b.PutInt(h.MaxWait) return nil } // Decode implements bin.Decoder. func (h *HTTPWaitRequest) Decode(b *bin.Buffer) error { if h == nil { return fmt.Errorf("can't decode http_wait#9299359f to nil") } if err := b.ConsumeID(HTTPWaitRequestTypeID); err != nil { return fmt.Errorf("unable to decode http_wait#9299359f: %w", err) } return h.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (h *HTTPWaitRequest) DecodeBare(b *bin.Buffer) error { if h == nil { return fmt.Errorf("can't decode http_wait#9299359f to nil") } { value, err := b.Int() if err != nil { return fmt.Errorf("unable to decode http_wait#9299359f: field max_delay: %w", err) } h.MaxDelay = value } { value, err := b.Int() if err != nil { return fmt.Errorf("unable to decode http_wait#9299359f: field wait_after: %w", err) } h.WaitAfter = value } { value, err := b.Int() if err != nil { return fmt.Errorf("unable to decode http_wait#9299359f: field max_wait: %w", err) } h.MaxWait = value } return nil } // GetMaxDelay returns value of MaxDelay field. func (h *HTTPWaitRequest) GetMaxDelay() (value int) { if h == nil { return } return h.MaxDelay } // GetWaitAfter returns value of WaitAfter field. func (h *HTTPWaitRequest) GetWaitAfter() (value int) { if h == nil { return } return h.WaitAfter } // GetMaxWait returns value of MaxWait field. func (h *HTTPWaitRequest) GetMaxWait() (value int) { if h == nil { return } return h.MaxWait }