Files
mautrix-telegram/pkg/gotd/tg/tl_web_page_slices_gen.go
T
2025-06-27 20:03:37 -07:00

669 lines
14 KiB
Go

//go:build !no_gotd_slices
// +build !no_gotd_slices
// Code generated by gotdgen, DO NOT EDIT.
package tg
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{}
)
// WebPageClassArray is adapter for slice of WebPageClass.
type WebPageClassArray []WebPageClass
// Sort sorts slice of WebPageClass.
func (s WebPageClassArray) Sort(less func(a, b WebPageClass) bool) WebPageClassArray {
sort.Slice(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// SortStable sorts slice of WebPageClass.
func (s WebPageClassArray) SortStable(less func(a, b WebPageClass) bool) WebPageClassArray {
sort.SliceStable(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// Retain filters in-place slice of WebPageClass.
func (s WebPageClassArray) Retain(keep func(x WebPageClass) bool) WebPageClassArray {
n := 0
for _, x := range s {
if keep(x) {
s[n] = x
n++
}
}
s = s[:n]
return s
}
// First returns first element of slice (if exists).
func (s WebPageClassArray) First() (v WebPageClass, ok bool) {
if len(s) < 1 {
return
}
return s[0], true
}
// Last returns last element of slice (if exists).
func (s WebPageClassArray) Last() (v WebPageClass, ok bool) {
if len(s) < 1 {
return
}
return s[len(s)-1], true
}
// PopFirst returns first element of slice (if exists) and deletes it.
func (s *WebPageClassArray) PopFirst() (v WebPageClass, ok bool) {
if s == nil || len(*s) < 1 {
return
}
a := *s
v = a[0]
// Delete by index from SliceTricks.
copy(a[0:], a[1:])
var zero WebPageClass
a[len(a)-1] = zero
a = a[:len(a)-1]
*s = a
return v, true
}
// Pop returns last element of slice (if exists) and deletes it.
func (s *WebPageClassArray) Pop() (v WebPageClass, ok bool) {
if s == nil || len(*s) < 1 {
return
}
a := *s
v = a[len(a)-1]
a = a[:len(a)-1]
*s = a
return v, true
}
// AsWebPageEmpty returns copy with only WebPageEmpty constructors.
func (s WebPageClassArray) AsWebPageEmpty() (to WebPageEmptyArray) {
for _, elem := range s {
value, ok := elem.(*WebPageEmpty)
if !ok {
continue
}
to = append(to, *value)
}
return to
}
// AsWebPagePending returns copy with only WebPagePending constructors.
func (s WebPageClassArray) AsWebPagePending() (to WebPagePendingArray) {
for _, elem := range s {
value, ok := elem.(*WebPagePending)
if !ok {
continue
}
to = append(to, *value)
}
return to
}
// AsWebPage returns copy with only WebPage constructors.
func (s WebPageClassArray) AsWebPage() (to WebPageArray) {
for _, elem := range s {
value, ok := elem.(*WebPage)
if !ok {
continue
}
to = append(to, *value)
}
return to
}
// AsWebPageNotModified returns copy with only WebPageNotModified constructors.
func (s WebPageClassArray) AsWebPageNotModified() (to WebPageNotModifiedArray) {
for _, elem := range s {
value, ok := elem.(*WebPageNotModified)
if !ok {
continue
}
to = append(to, *value)
}
return to
}
// FillModifiedMap fills only Modified constructors to given map.
func (s WebPageClassArray) FillModifiedMap(to map[int64]ModifiedWebPage) {
for _, elem := range s {
value, ok := elem.AsModified()
if !ok {
continue
}
to[value.GetID()] = value
}
}
// ModifiedToMap collects only Modified constructors to map.
func (s WebPageClassArray) ModifiedToMap() map[int64]ModifiedWebPage {
r := make(map[int64]ModifiedWebPage, len(s))
s.FillModifiedMap(r)
return r
}
// AppendOnlyModified appends only Modified constructors to
// given slice.
func (s WebPageClassArray) AppendOnlyModified(to []ModifiedWebPage) []ModifiedWebPage {
for _, elem := range s {
value, ok := elem.AsModified()
if !ok {
continue
}
to = append(to, value)
}
return to
}
// AsModified returns copy with only Modified constructors.
func (s WebPageClassArray) AsModified() (to []ModifiedWebPage) {
return s.AppendOnlyModified(to)
}
// FirstAsModified returns first element of slice (if exists).
func (s WebPageClassArray) FirstAsModified() (v ModifiedWebPage, ok bool) {
value, ok := s.First()
if !ok {
return
}
return value.AsModified()
}
// LastAsModified returns last element of slice (if exists).
func (s WebPageClassArray) LastAsModified() (v ModifiedWebPage, ok bool) {
value, ok := s.Last()
if !ok {
return
}
return value.AsModified()
}
// PopFirstAsModified returns element of slice (if exists).
func (s *WebPageClassArray) PopFirstAsModified() (v ModifiedWebPage, ok bool) {
value, ok := s.PopFirst()
if !ok {
return
}
return value.AsModified()
}
// PopAsModified returns element of slice (if exists).
func (s *WebPageClassArray) PopAsModified() (v ModifiedWebPage, ok bool) {
value, ok := s.Pop()
if !ok {
return
}
return value.AsModified()
}
// WebPageEmptyArray is adapter for slice of WebPageEmpty.
type WebPageEmptyArray []WebPageEmpty
// Sort sorts slice of WebPageEmpty.
func (s WebPageEmptyArray) Sort(less func(a, b WebPageEmpty) bool) WebPageEmptyArray {
sort.Slice(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// SortStable sorts slice of WebPageEmpty.
func (s WebPageEmptyArray) SortStable(less func(a, b WebPageEmpty) bool) WebPageEmptyArray {
sort.SliceStable(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// Retain filters in-place slice of WebPageEmpty.
func (s WebPageEmptyArray) Retain(keep func(x WebPageEmpty) bool) WebPageEmptyArray {
n := 0
for _, x := range s {
if keep(x) {
s[n] = x
n++
}
}
s = s[:n]
return s
}
// First returns first element of slice (if exists).
func (s WebPageEmptyArray) First() (v WebPageEmpty, ok bool) {
if len(s) < 1 {
return
}
return s[0], true
}
// Last returns last element of slice (if exists).
func (s WebPageEmptyArray) Last() (v WebPageEmpty, ok bool) {
if len(s) < 1 {
return
}
return s[len(s)-1], true
}
// PopFirst returns first element of slice (if exists) and deletes it.
func (s *WebPageEmptyArray) PopFirst() (v WebPageEmpty, ok bool) {
if s == nil || len(*s) < 1 {
return
}
a := *s
v = a[0]
// Delete by index from SliceTricks.
copy(a[0:], a[1:])
var zero WebPageEmpty
a[len(a)-1] = zero
a = a[:len(a)-1]
*s = a
return v, true
}
// Pop returns last element of slice (if exists) and deletes it.
func (s *WebPageEmptyArray) Pop() (v WebPageEmpty, ok bool) {
if s == nil || len(*s) < 1 {
return
}
a := *s
v = a[len(a)-1]
a = a[:len(a)-1]
*s = a
return v, true
}
// SortByID sorts slice of WebPageEmpty by ID.
func (s WebPageEmptyArray) SortByID() WebPageEmptyArray {
return s.Sort(func(a, b WebPageEmpty) bool {
return a.GetID() < b.GetID()
})
}
// SortStableByID sorts slice of WebPageEmpty by ID.
func (s WebPageEmptyArray) SortStableByID() WebPageEmptyArray {
return s.SortStable(func(a, b WebPageEmpty) bool {
return a.GetID() < b.GetID()
})
}
// FillMap fills constructors to given map.
func (s WebPageEmptyArray) FillMap(to map[int64]WebPageEmpty) {
for _, value := range s {
to[value.GetID()] = value
}
}
// ToMap collects constructors to map.
func (s WebPageEmptyArray) ToMap() map[int64]WebPageEmpty {
r := make(map[int64]WebPageEmpty, len(s))
s.FillMap(r)
return r
}
// WebPagePendingArray is adapter for slice of WebPagePending.
type WebPagePendingArray []WebPagePending
// Sort sorts slice of WebPagePending.
func (s WebPagePendingArray) Sort(less func(a, b WebPagePending) bool) WebPagePendingArray {
sort.Slice(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// SortStable sorts slice of WebPagePending.
func (s WebPagePendingArray) SortStable(less func(a, b WebPagePending) bool) WebPagePendingArray {
sort.SliceStable(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// Retain filters in-place slice of WebPagePending.
func (s WebPagePendingArray) Retain(keep func(x WebPagePending) bool) WebPagePendingArray {
n := 0
for _, x := range s {
if keep(x) {
s[n] = x
n++
}
}
s = s[:n]
return s
}
// First returns first element of slice (if exists).
func (s WebPagePendingArray) First() (v WebPagePending, ok bool) {
if len(s) < 1 {
return
}
return s[0], true
}
// Last returns last element of slice (if exists).
func (s WebPagePendingArray) Last() (v WebPagePending, ok bool) {
if len(s) < 1 {
return
}
return s[len(s)-1], true
}
// PopFirst returns first element of slice (if exists) and deletes it.
func (s *WebPagePendingArray) PopFirst() (v WebPagePending, ok bool) {
if s == nil || len(*s) < 1 {
return
}
a := *s
v = a[0]
// Delete by index from SliceTricks.
copy(a[0:], a[1:])
var zero WebPagePending
a[len(a)-1] = zero
a = a[:len(a)-1]
*s = a
return v, true
}
// Pop returns last element of slice (if exists) and deletes it.
func (s *WebPagePendingArray) Pop() (v WebPagePending, ok bool) {
if s == nil || len(*s) < 1 {
return
}
a := *s
v = a[len(a)-1]
a = a[:len(a)-1]
*s = a
return v, true
}
// SortByID sorts slice of WebPagePending by ID.
func (s WebPagePendingArray) SortByID() WebPagePendingArray {
return s.Sort(func(a, b WebPagePending) bool {
return a.GetID() < b.GetID()
})
}
// SortStableByID sorts slice of WebPagePending by ID.
func (s WebPagePendingArray) SortStableByID() WebPagePendingArray {
return s.SortStable(func(a, b WebPagePending) bool {
return a.GetID() < b.GetID()
})
}
// SortByDate sorts slice of WebPagePending by Date.
func (s WebPagePendingArray) SortByDate() WebPagePendingArray {
return s.Sort(func(a, b WebPagePending) bool {
return a.GetDate() < b.GetDate()
})
}
// SortStableByDate sorts slice of WebPagePending by Date.
func (s WebPagePendingArray) SortStableByDate() WebPagePendingArray {
return s.SortStable(func(a, b WebPagePending) bool {
return a.GetDate() < b.GetDate()
})
}
// FillMap fills constructors to given map.
func (s WebPagePendingArray) FillMap(to map[int64]WebPagePending) {
for _, value := range s {
to[value.GetID()] = value
}
}
// ToMap collects constructors to map.
func (s WebPagePendingArray) ToMap() map[int64]WebPagePending {
r := make(map[int64]WebPagePending, len(s))
s.FillMap(r)
return r
}
// WebPageArray is adapter for slice of WebPage.
type WebPageArray []WebPage
// Sort sorts slice of WebPage.
func (s WebPageArray) Sort(less func(a, b WebPage) bool) WebPageArray {
sort.Slice(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// SortStable sorts slice of WebPage.
func (s WebPageArray) SortStable(less func(a, b WebPage) bool) WebPageArray {
sort.SliceStable(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// Retain filters in-place slice of WebPage.
func (s WebPageArray) Retain(keep func(x WebPage) bool) WebPageArray {
n := 0
for _, x := range s {
if keep(x) {
s[n] = x
n++
}
}
s = s[:n]
return s
}
// First returns first element of slice (if exists).
func (s WebPageArray) First() (v WebPage, ok bool) {
if len(s) < 1 {
return
}
return s[0], true
}
// Last returns last element of slice (if exists).
func (s WebPageArray) Last() (v WebPage, ok bool) {
if len(s) < 1 {
return
}
return s[len(s)-1], true
}
// PopFirst returns first element of slice (if exists) and deletes it.
func (s *WebPageArray) PopFirst() (v WebPage, ok bool) {
if s == nil || len(*s) < 1 {
return
}
a := *s
v = a[0]
// Delete by index from SliceTricks.
copy(a[0:], a[1:])
var zero WebPage
a[len(a)-1] = zero
a = a[:len(a)-1]
*s = a
return v, true
}
// Pop returns last element of slice (if exists) and deletes it.
func (s *WebPageArray) Pop() (v WebPage, ok bool) {
if s == nil || len(*s) < 1 {
return
}
a := *s
v = a[len(a)-1]
a = a[:len(a)-1]
*s = a
return v, true
}
// SortByID sorts slice of WebPage by ID.
func (s WebPageArray) SortByID() WebPageArray {
return s.Sort(func(a, b WebPage) bool {
return a.GetID() < b.GetID()
})
}
// SortStableByID sorts slice of WebPage by ID.
func (s WebPageArray) SortStableByID() WebPageArray {
return s.SortStable(func(a, b WebPage) bool {
return a.GetID() < b.GetID()
})
}
// FillMap fills constructors to given map.
func (s WebPageArray) FillMap(to map[int64]WebPage) {
for _, value := range s {
to[value.GetID()] = value
}
}
// ToMap collects constructors to map.
func (s WebPageArray) ToMap() map[int64]WebPage {
r := make(map[int64]WebPage, len(s))
s.FillMap(r)
return r
}
// WebPageNotModifiedArray is adapter for slice of WebPageNotModified.
type WebPageNotModifiedArray []WebPageNotModified
// Sort sorts slice of WebPageNotModified.
func (s WebPageNotModifiedArray) Sort(less func(a, b WebPageNotModified) bool) WebPageNotModifiedArray {
sort.Slice(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// SortStable sorts slice of WebPageNotModified.
func (s WebPageNotModifiedArray) SortStable(less func(a, b WebPageNotModified) bool) WebPageNotModifiedArray {
sort.SliceStable(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// Retain filters in-place slice of WebPageNotModified.
func (s WebPageNotModifiedArray) Retain(keep func(x WebPageNotModified) bool) WebPageNotModifiedArray {
n := 0
for _, x := range s {
if keep(x) {
s[n] = x
n++
}
}
s = s[:n]
return s
}
// First returns first element of slice (if exists).
func (s WebPageNotModifiedArray) First() (v WebPageNotModified, ok bool) {
if len(s) < 1 {
return
}
return s[0], true
}
// Last returns last element of slice (if exists).
func (s WebPageNotModifiedArray) Last() (v WebPageNotModified, ok bool) {
if len(s) < 1 {
return
}
return s[len(s)-1], true
}
// PopFirst returns first element of slice (if exists) and deletes it.
func (s *WebPageNotModifiedArray) PopFirst() (v WebPageNotModified, ok bool) {
if s == nil || len(*s) < 1 {
return
}
a := *s
v = a[0]
// Delete by index from SliceTricks.
copy(a[0:], a[1:])
var zero WebPageNotModified
a[len(a)-1] = zero
a = a[:len(a)-1]
*s = a
return v, true
}
// Pop returns last element of slice (if exists) and deletes it.
func (s *WebPageNotModifiedArray) Pop() (v WebPageNotModified, ok bool) {
if s == nil || len(*s) < 1 {
return
}
a := *s
v = a[len(a)-1]
a = a[:len(a)-1]
*s = a
return v, true
}