package httpx

import 

// Result contains the decoded response body and response metadata.
type Result[ any] struct {
	Body     
	Response *req.Response
	Err      error
}

// Option applies configuration to a client or request.
type Option interface {
	applyClient(*Client)
	applyRequest(*req.Request)
}

type option struct {
	clientFn  func(*Client)
	requestFn func(*req.Request)
}

func ( option) ( *Client) {
	if .clientFn == nil {
		return
	}
	.clientFn()
}

func ( option) ( *req.Request) {
	if .requestFn == nil {
		return
	}
	.requestFn()
}

func clientOnly( func(*Client)) Option {
	return option{clientFn: }
}

func requestOnly( func(*req.Request)) Option {
	return option{requestFn: }
}

func bothOption( func(*Client),  func(*req.Request)) Option {
	return option{
		clientFn:  ,
		requestFn: ,
	}
}

// OptionBuilder chains request and client options.
// @group Options
//
// Example: chain options
//
//	opt := httpx.Header("X-Trace", "1").Query("q", "go")
//	_ = opt
type OptionBuilder struct {
	ops []Option
}

func ( OptionBuilder) ( Option) OptionBuilder {
	.ops = append(.ops, )
	return 
}

func ( OptionBuilder) ( *Client) {
	for ,  := range .ops {
		if  == nil {
			continue
		}
		.applyClient()
	}
}

func ( OptionBuilder) ( *req.Request) {
	for ,  := range .ops {
		if  == nil {
			continue
		}
		.applyRequest()
	}
}

// ErrorMapperFunc customizes error creation for non-2xx responses.
type ErrorMapperFunc func(*req.Response) error