package gojay

import (
	
)

// Unsafe is the structure holding the unsafe version of the API.
// The difference between unsafe api and regular api is that the regular API
// copies the buffer passed to Unmarshal functions to a new internal buffer.
// Making it safer because internally GoJay uses unsafe.Pointer to transform slice of bytes into a string.
var Unsafe = decUnsafe{}

type decUnsafe struct{}

func ( decUnsafe) ( []byte,  UnmarshalerJSONArray) error {
	 := borrowDecoder(nil, 0)
	defer .Release()
	.data = 
	.length = len()
	,  := .decodeArray()
	return 
}

func ( decUnsafe) ( []byte,  UnmarshalerJSONObject) error {
	 := borrowDecoder(nil, 0)
	defer .Release()
	.data = 
	.length = len()
	,  := .decodeObject()
	return 
}

func ( decUnsafe) ( []byte,  interface{}) error {
	var  error
	var  *Decoder
	switch vt := .(type) {
	case *string:
		 = borrowDecoder(nil, 0)
		.length = len()
		.data = 
		 = .decodeString()
	case *int:
		 = borrowDecoder(nil, 0)
		.length = len()
		.data = 
		 = .decodeInt()
	case *int8:
		 = borrowDecoder(nil, 0)
		.length = len()
		.data = 
		 = .decodeInt8()
	case *int16:
		 = borrowDecoder(nil, 0)
		.length = len()
		.data = 
		 = .decodeInt16()
	case *int32:
		 = borrowDecoder(nil, 0)
		.length = len()
		.data = 
		 = .decodeInt32()
	case *int64:
		 = borrowDecoder(nil, 0)
		.length = len()
		.data = 
		 = .decodeInt64()
	case *uint8:
		 = borrowDecoder(nil, 0)
		.length = len()
		.data = 
		 = .decodeUint8()
	case *uint16:
		 = borrowDecoder(nil, 0)
		.length = len()
		.data = 
		 = .decodeUint16()
	case *uint32:
		 = borrowDecoder(nil, 0)
		.length = len()
		.data = 
		 = .decodeUint32()
	case *uint64:
		 = borrowDecoder(nil, 0)
		.length = len()
		.data = 
		 = .decodeUint64()
	case *float64:
		 = borrowDecoder(nil, 0)
		.length = len()
		.data = 
		 = .decodeFloat64()
	case *float32:
		 = borrowDecoder(nil, 0)
		.length = len()
		.data = 
		 = .decodeFloat32()
	case *bool:
		 = borrowDecoder(nil, 0)
		.length = len()
		.data = 
		 = .decodeBool()
	case UnmarshalerJSONObject:
		 = borrowDecoder(nil, 0)
		.length = len()
		.data = 
		_,  = .decodeObject()
	case UnmarshalerJSONArray:
		 = borrowDecoder(nil, 0)
		.length = len()
		.data = 
		_,  = .decodeArray()
	default:
		return InvalidUnmarshalError(fmt.Sprintf(invalidUnmarshalErrorMsg, ))
	}
	defer .Release()
	if  != nil {
		return 
	}
	return .err
}