package privatetypes

// Code generated by "go run types_generate.go"; DO NOT EDIT.

import (
	"fmt"
	"strconv"

	dnsv2 "codeberg.org/miekg/dns"
	dnsutilv2 "codeberg.org/miekg/dns/dnsutil"
	"github.com/DNSControl/dnscontrol/v5/pkg/mustbe"
	privatetypesrdata "github.com/DNSControl/dnscontrol/v5/pkg/privatetypes/rdata"
)

// IMPORT_TRANSFORM

func init() {
	Register(TypeIMPORTTRANSFORM, "IMPORT_TRANSFORM", func() dnsv2.RR { return new(IMPORTTRANSFORM) }, privatetypesrdata.MakeIMPORTTRANSFORM)
}

const TypeIMPORTTRANSFORM = uint16(65322)

type IMPORTTRANSFORM struct {
	Hdr dnsv2.Header

	privatetypesrdata.IMPORTTRANSFORM
	// TransformTable       string
	// TTL                  uint16
	// SuffixStrip          string
	// TargetDomain         string
}

// Typer interface.

func (rr *IMPORTTRANSFORM) Type() uint16 { return TypeIMPORTTRANSFORM }

// RR interface.

func (rr *IMPORTTRANSFORM) Header() *dnsv2.Header { return &rr.Hdr }
func (rr *IMPORTTRANSFORM) Len() int {
	return rr.Hdr.Len() + rr.Data().Len()
}
func (rr *IMPORTTRANSFORM) Data() dnsv2.RDATA {
	return privatetypesrdata.IMPORTTRANSFORM{TransformTable: rr.TransformTable, TTL: rr.TTL, SuffixStrip: rr.SuffixStrip, TargetDomain: rr.TargetDomain}
}
func (rr *IMPORTTRANSFORM) Clone() dnsv2.RR {
	return &IMPORTTRANSFORM{
		Hdr:            rr.Hdr,
		TransformTable: rr.TransformTable,
		TTL:            rr.TTL,
		SuffixStrip:    rr.SuffixStrip,
		TargetDomain:   rr.TargetDomain}
}
func (rr *IMPORTTRANSFORM) String() string {
	return (rr.Header().Name + "\t" +
		strconv.FormatInt(int64(rr.Header().TTL), 10) + "\t" +
		dnsutilv2.ClassToString(rr.Header().Class) + "\tIMPORT_TRANSFORM\t" + rr.Data().String())
}

// Parse makes an RDATA for this type using the tokens from dnsv2's parser.
func (rr *IMPORTTRANSFORM) Parse(tokens []string, s string) error {
	args := TokensToArgs(tokens)
	if len(args) != 4 {
		return fmt.Errorf("IMPORT_TRANSFORM requires exactly 4 arguments, got %d: %v", len(args), args)
	}
	rr.TransformTable = mustbe.RawString(args[0])
	rr.TTL = mustbe.Uint16(args[1])
	rr.SuffixStrip = mustbe.RawString(args[2])
	rr.TargetDomain = mustbe.RawString(args[3])
	return nil
}

// Code generated by "go run types_generate.go"; DO NOT EDIT.
