// 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{} ) // SecureData represents TL type `secureData#8aeabec3`. // Secure passport¹ data, for more info see the passport docs »² // // Links: // 1. https://core.telegram.org/passport // 2. https://core.telegram.org/passport/encryption#securedata // // See https://core.telegram.org/constructor/secureData for reference. type SecureData struct { // Data Data []byte // Data hash DataHash []byte // Secret Secret []byte } // SecureDataTypeID is TL type id of SecureData. const SecureDataTypeID = 0x8aeabec3 // Ensuring interfaces in compile-time for SecureData. var ( _ bin.Encoder = &SecureData{} _ bin.Decoder = &SecureData{} _ bin.BareEncoder = &SecureData{} _ bin.BareDecoder = &SecureData{} ) func (s *SecureData) Zero() bool { if s == nil { return true } if !(s.Data == nil) { return false } if !(s.DataHash == nil) { return false } if !(s.Secret == nil) { return false } return true } // String implements fmt.Stringer. func (s *SecureData) String() string { if s == nil { return "SecureData(nil)" } type Alias SecureData return fmt.Sprintf("SecureData%+v", Alias(*s)) } // FillFrom fills SecureData from given interface. func (s *SecureData) FillFrom(from interface { GetData() (value []byte) GetDataHash() (value []byte) GetSecret() (value []byte) }) { s.Data = from.GetData() s.DataHash = from.GetDataHash() s.Secret = from.GetSecret() } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*SecureData) TypeID() uint32 { return SecureDataTypeID } // TypeName returns name of type in TL schema. func (*SecureData) TypeName() string { return "secureData" } // TypeInfo returns info about TL type. func (s *SecureData) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "secureData", ID: SecureDataTypeID, } if s == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "Data", SchemaName: "data", }, { Name: "DataHash", SchemaName: "data_hash", }, { Name: "Secret", SchemaName: "secret", }, } return typ } // Encode implements bin.Encoder. func (s *SecureData) Encode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode secureData#8aeabec3 as nil") } b.PutID(SecureDataTypeID) return s.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (s *SecureData) EncodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode secureData#8aeabec3 as nil") } b.PutBytes(s.Data) b.PutBytes(s.DataHash) b.PutBytes(s.Secret) return nil } // Decode implements bin.Decoder. func (s *SecureData) Decode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode secureData#8aeabec3 to nil") } if err := b.ConsumeID(SecureDataTypeID); err != nil { return fmt.Errorf("unable to decode secureData#8aeabec3: %w", err) } return s.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (s *SecureData) DecodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode secureData#8aeabec3 to nil") } { value, err := b.Bytes() if err != nil { return fmt.Errorf("unable to decode secureData#8aeabec3: field data: %w", err) } s.Data = value } { value, err := b.Bytes() if err != nil { return fmt.Errorf("unable to decode secureData#8aeabec3: field data_hash: %w", err) } s.DataHash = value } { value, err := b.Bytes() if err != nil { return fmt.Errorf("unable to decode secureData#8aeabec3: field secret: %w", err) } s.Secret = value } return nil } // GetData returns value of Data field. func (s *SecureData) GetData() (value []byte) { if s == nil { return } return s.Data } // GetDataHash returns value of DataHash field. func (s *SecureData) GetDataHash() (value []byte) { if s == nil { return } return s.DataHash } // GetSecret returns value of Secret field. func (s *SecureData) GetSecret() (value []byte) { if s == nil { return } return s.Secret }