// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// 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{}
)

// ContactStatus represents TL type `contactStatus#16d9703b`.
// Contact status: online / offline.
//
// See https://core.telegram.org/constructor/contactStatus for reference.
type ContactStatus struct {
	// User identifier
	UserID int64
	// Online status
	Status UserStatusClass
}

// ContactStatusTypeID is TL type id of ContactStatus.
const ContactStatusTypeID = 0x16d9703b

// Ensuring interfaces in compile-time for ContactStatus.
var (
	_ bin.Encoder     = &ContactStatus{}
	_ bin.Decoder     = &ContactStatus{}
	_ bin.BareEncoder = &ContactStatus{}
	_ bin.BareDecoder = &ContactStatus{}
)

func ( *ContactStatus) () bool {
	if  == nil {
		return true
	}
	if !(.UserID == 0) {
		return false
	}
	if !(.Status == nil) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *ContactStatus) () string {
	if  == nil {
		return "ContactStatus(nil)"
	}
	type  ContactStatus
	return fmt.Sprintf("ContactStatus%+v", (*))
}

// FillFrom fills ContactStatus from given interface.
func ( *ContactStatus) ( interface {
	() ( int64)
	() ( UserStatusClass)
}) {
	.UserID = .()
	.Status = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*ContactStatus) () uint32 {
	return ContactStatusTypeID
}

// TypeName returns name of type in TL schema.
func (*ContactStatus) () string {
	return "contactStatus"
}

// TypeInfo returns info about TL type.
func ( *ContactStatus) () tdp.Type {
	 := tdp.Type{
		Name: "contactStatus",
		ID:   ContactStatusTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "Status",
			SchemaName: "status",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ContactStatus) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contactStatus#16d9703b as nil")
	}
	.PutID(ContactStatusTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ContactStatus) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contactStatus#16d9703b as nil")
	}
	.PutLong(.UserID)
	if .Status == nil {
		return fmt.Errorf("unable to encode contactStatus#16d9703b: field status is nil")
	}
	if  := .Status.Encode();  != nil {
		return fmt.Errorf("unable to encode contactStatus#16d9703b: field status: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *ContactStatus) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode contactStatus#16d9703b to nil")
	}
	if  := .ConsumeID(ContactStatusTypeID);  != nil {
		return fmt.Errorf("unable to decode contactStatus#16d9703b: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ContactStatus) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode contactStatus#16d9703b to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode contactStatus#16d9703b: field user_id: %w", )
		}
		.UserID = 
	}
	{
		,  := DecodeUserStatus()
		if  != nil {
			return fmt.Errorf("unable to decode contactStatus#16d9703b: field status: %w", )
		}
		.Status = 
	}
	return nil
}

// GetUserID returns value of UserID field.
func ( *ContactStatus) () ( int64) {
	if  == nil {
		return
	}
	return .UserID
}

// GetStatus returns value of Status field.
func ( *ContactStatus) () ( UserStatusClass) {
	if  == nil {
		return
	}
	return .Status
}