// Code generated by ndpgen. DO NOT EDIT.
//
// This file contains type definitions for non-WASM builds.
// These types match the extism/go-pdk signatures to allow compilation and testing
// on native platforms without importing the WASM-only extism package.
//
//go:build !wasip1

package pdk

// LogLevel represents a logging level.
type LogLevel int

// Log level constants
const (
	LogTrace LogLevel = iota
	LogDebug
	LogInfo
	LogWarn
	LogError
)

// HTTPMethod represents an HTTP method.
type HTTPMethod int32

// HTTP method constants
const (
	MethodGet HTTPMethod = iota
	MethodHead
	MethodPost
	MethodPut
	MethodPatch
	MethodDelete
	MethodConnect
	MethodOptions
	MethodTrace
)

// String returns the string representation of the HTTP method.
func (m HTTPMethod) String() string {
	switch m {
	case MethodGet:
		return "GET"
	case MethodHead:
		return "HEAD"
	case MethodPost:
		return "POST"
	case MethodPut:
		return "PUT"
	case MethodPatch:
		return "PATCH"
	case MethodDelete:
		return "DELETE"
	case MethodConnect:
		return "CONNECT"
	case MethodOptions:
		return "OPTIONS"
	case MethodTrace:
		return "TRACE"
	default:
		return "UNKNOWN"
	}
}

// Memory represents memory allocated by (and shared with) the host.
// This is a stub implementation for non-WASM platforms.
type Memory struct {
	offset uint64
	length uint64
	data   []byte
}

// Offset returns the offset of the memory block.
func (m Memory) Offset() uint64 {
	return m.offset
}

// Length returns the length of the memory block.
func (m Memory) Length() uint64 {
	return m.length
}

// ReadBytes reads all bytes from the memory block.
func (m Memory) ReadBytes() []byte {
	return m.data
}

// Load reads the memory block into the provided buffer.
func (m *Memory) Load(buffer []byte) {
	copy(buffer, m.data)
}

// Store writes data to the memory block.
func (m *Memory) Store(data []byte) {
	m.data = make([]byte, len(data))
	copy(m.data, data)
	m.length = uint64(len(data))
}

// Free frees the memory block.
func (m *Memory) Free() {
	m.data = nil
	m.length = 0
}

// NewStubMemory creates a new stub Memory for testing.
// This is a helper function not present in the real PDK.
func NewStubMemory(offset, length uint64, data []byte) Memory {
	return Memory{
		offset: offset,
		length: length,
		data:   data,
	}
}

// HTTPRequest represents an HTTP request sent by the host.
// This is a stub implementation for non-WASM platforms.
type HTTPRequest struct {
	method  HTTPMethod
	url     string
	headers map[string]string
	body    []byte
}

// SetHeader sets an HTTP header key to value.
func (r *HTTPRequest) SetHeader(key string, value string) *HTTPRequest {
	if r.headers == nil {
		r.headers = make(map[string]string)
	}
	r.headers[key] = value
	return r
}

// SetBody sets the HTTP request body.
func (r *HTTPRequest) SetBody(body []byte) *HTTPRequest {
	r.body = body
	return r
}

// Send sends the HTTP request and returns the response.
// In the stub implementation, this delegates to the mock.
func (r *HTTPRequest) Send() HTTPResponse {
	args := PDKMock.Called(r)
	return args.Get(0).(HTTPResponse)
}

// HTTPRequestMeta represents the metadata associated with an HTTP request.
type HTTPRequestMeta struct {
	URL     string            `json:"url"`
	Method  string            `json:"method"`
	Headers map[string]string `json:"headers"`
}

// HTTPResponse represents an HTTP response returned from the host.
// This is a stub implementation for non-WASM platforms.
type HTTPResponse struct {
	status  uint16
	headers map[string]string
	body    []byte
	memory  Memory
}

// Status returns the status code from the response.
func (r HTTPResponse) Status() uint16 {
	return r.status
}

// Headers returns the HTTP response headers.
func (r *HTTPResponse) Headers() map[string]string {
	return r.headers
}

// Body returns the body byte slice from the response.
func (r HTTPResponse) Body() []byte {
	return r.body
}

// Memory returns the memory associated with the response.
func (r HTTPResponse) Memory() Memory {
	return r.memory
}

// NewStubHTTPResponse creates a new stub HTTPResponse for testing.
// This is a helper function not present in the real PDK.
func NewStubHTTPResponse(status uint16, headers map[string]string, body []byte) HTTPResponse {
	return HTTPResponse{
		status:  status,
		headers: headers,
		body:    body,
		memory:  NewStubMemory(0, uint64(len(body)), body),
	}
}
