// Generated by Lisette bindgen
// Source: net/http/httptrace (Go stdlib)
// Go: 1.25.10
// Lisette: 0.3.0

import "go:context"
import "go:crypto/tls"
import "go:net"
import "go:net/textproto"
import "go:time"

/// ContextClientTrace returns the [ClientTrace] associated with the
/// provided context. If none, it returns nil.
pub fn ContextClientTrace(ctx: context.Context) -> Option<Ref<ClientTrace>>

/// WithClientTrace returns a new context based on the provided parent
/// ctx. HTTP client requests made with the returned context will use
/// the provided trace hooks, in addition to any previous hooks
/// registered with ctx. Any hooks defined in the provided trace will
/// be called first.
pub fn WithClientTrace(ctx: context.Context, trace: Ref<ClientTrace>) -> context.Context

/// ClientTrace is a set of hooks to run at various stages of an outgoing
/// HTTP request. Any particular hook may be nil. Functions may be
/// called concurrently from different goroutines and some may be called
/// after the request has completed or failed.
/// 
/// ClientTrace currently traces a single HTTP request & response
/// during a single round trip and has no hooks that span a series
/// of redirected requests.
/// 
/// See https://blog.golang.org/http-tracing for more.
pub struct ClientTrace {
  pub GetConn: Option<fn(string) -> ()>,
  pub GotConn: Option<fn(GotConnInfo) -> ()>,
  pub PutIdleConn: Option<fn(error) -> ()>,
  pub GotFirstResponseByte: Option<fn() -> ()>,
  pub Got100Continue: Option<fn() -> ()>,
  pub Got1xxResponse: Option<fn(int, textproto.MIMEHeader) -> Result<(), error>>,
  pub DNSStart: Option<fn(DNSStartInfo) -> ()>,
  pub DNSDone: Option<fn(DNSDoneInfo) -> ()>,
  pub ConnectStart: Option<fn(string, string) -> ()>,
  pub ConnectDone: Option<fn(string, string, error) -> ()>,
  pub TLSHandshakeStart: Option<fn() -> ()>,
  pub TLSHandshakeDone: Option<fn(tls.ConnectionState, error) -> ()>,
  pub WroteHeaderField: Option<fn(string, Slice<string>) -> ()>,
  pub WroteHeaders: Option<fn() -> ()>,
  pub Wait100Continue: Option<fn() -> ()>,
  pub WroteRequest: Option<fn(WroteRequestInfo) -> ()>,
}

/// DNSDoneInfo contains information about the results of a DNS lookup.
pub struct DNSDoneInfo {
  pub Addrs: Slice<net.IPAddr>,
  pub Err: error,
  pub Coalesced: bool,
}

/// DNSStartInfo contains information about a DNS request.
pub struct DNSStartInfo {
  pub Host: string,
}

/// GotConnInfo is the argument to the [ClientTrace.GotConn] function and
/// contains information about the obtained connection.
pub struct GotConnInfo {
  pub Conn: Option<net.Conn>,
  pub Reused: bool,
  pub WasIdle: bool,
  pub IdleTime: time.Duration,
}

/// WroteRequestInfo contains information provided to the WroteRequest
/// hook.
pub struct WroteRequestInfo {
  pub Err: error,
}
