//go:build (amd64 || arm64) && !purego
// +build amd64 arm64
// +build !purego

package base64

import (
	

	
)

// An Encoding is a radix 64 encoding/decoding scheme, defined by a
// 64-character alphabet.
type Encoding struct {
	enc    func(dst []byte, src []byte, lut *int8) (int, int)
	enclut [encLutSize]int8

	dec    func(dst []byte, src []byte, lut *int8) (int, int)
	declut [decLutSize]int8

	base *base64.Encoding
}

// WithPadding creates a duplicate Encoding updated with a specified padding
// character, or NoPadding to disable padding. The padding character must not
// be contained in the encoding alphabet, must not be '\r' or '\n', and must
// be no greater than '\xFF'.
func ( Encoding) ( rune) *Encoding {
	.base = .base.WithPadding()
	return &
}

// Strict creates a duplicate encoding updated with strict decoding enabled.
// This requires that trailing padding bits are zero.
func ( Encoding) () *Encoding {
	.base = .base.Strict()
	return &
}

// Encode encodes src using the defined encoding alphabet.
// This will write EncodedLen(len(src)) bytes to dst.
func ( *Encoding) (,  []byte) {
	if len() >= minEncodeLen && .enc != nil {
		,  := .enc(, , &.enclut[0])
		 = [:]
		 = [:]
	}
	.base.Encode(, )
}

// Encode encodes src using the encoding enc, writing
// EncodedLen(len(src)) bytes to dst.
func ( *Encoding) ( []byte) string {
	 := make([]byte, .base.EncodedLen(len()))
	.Encode(, )
	return string()
}

// EncodedLen calculates the base64-encoded byte length for a message
// of length n.
func ( *Encoding) ( int) int {
	return .base.EncodedLen()
}

// Decode decodes src using the defined encoding alphabet.
// This will write DecodedLen(len(src)) bytes to dst and return the number of
// bytes written.
func ( *Encoding) (,  []byte) ( int,  error) {
	var ,  int
	if len() >= minDecodeLen && .dec != nil {
		,  = .dec(, , &.declut[0])
		 = [:]
		 = [:]
	}
	,  = .base.Decode(, )
	 += 
	return
}

// DecodeString decodes the base64 encoded string s, returns the decoded
// value as bytes.
func ( *Encoding) ( string) ([]byte, error) {
	 := unsafebytes.BytesOf()
	 := make([]byte, .base.DecodedLen(len()))
	,  := .Decode(, )
	return [:], 
}

// DecodedLen calculates the decoded byte length for a base64-encoded message
// of length n.
func ( *Encoding) ( int) int {
	return .base.DecodedLen()
}