Silk

silk/http_client_native

Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc.

Native connection acquisition for one HTTP origin and one serial client scope.

Details

HTTPS authenticates the original origin with explicit trust. Absolute deadlines are unchanged through resolution, connection, and TLS authentication. Synchronous hostname resolution rejects an overall deadline before dispatch. Cleanup closes without a flush or TLS shutdown.

Gotchas

On unsupported targets or no-libc profiles, reached native acquisition produces a compile-time error. Unused imports and portable configuration remain available.

Import as HttpClientNative with import silk.http_client_native as HttpClientNative.

Public declarations: 16.

NativeRoute

pub struct NativeRoute

The immutable transport route retained independently of the HTTP origin.

Method NativeRoute.isUnix

pub fn isUnix<'life0>(self: &'life0 NativeRoute) -> bool

Returns whether this route uses an explicit Unix socket path.

Method NativeRoute.path

pub fn path<'a>(self: &'a NativeRoute) -> &'a [u8]

Borrows the exact owned Unix path, or an empty slice for direct TCP.

Implementation Copy for NativeRoute

impl Copy for NativeRoute

NativeClientError

pub union NativeClientError

A native HTTP option admission or authentication failure.

InvalidConnectOptions

NativeClientError.InvalidConnectOptions: NativeClientError

The native polling interval or attempt count is outside its finite accepted range.

UnsupportedDeadline

NativeClientError.UnsupportedDeadline: NativeClientError

Synchronous hostname resolution cannot honor the supplied overall deadline.

TrustRequired

NativeClientError.TrustRequired: NativeClientError

HTTPS owned acquisition requires one caller-prepared frozen trust snapshot.

AlpnMismatch

NativeClientError.AlpnMismatch { error: ConnectionError }: NativeClientError

Required HTTP/1.1 application protocol negotiation did not succeed.

Field error

pub error: ConnectionError

The complete TLS connection failure.

AlpnPolicy

pub enum AlpnPolicy

The HTTP version policy for TLS application protocol negotiation.

OptionalHttp11

OptionalHttp11 = 0

Offers only http/1.1 and permits an absent selection.

RequiredHttp11

RequiredHttp11 = 1

Requires the peer to select http/1.1.

Http10

Http10 = 2

Sends no ALPN extension for an HTTP/1.0-only peer.

Options

pub struct Options

Finite native acquisition and TLS authentication limits.

Field maximumAddresses

pub maximumAddresses: usize

Maximum number of resolved numeric addresses.

Field family

pub family: FamilySelection

Address family admitted by resolution.

Field noDelay

pub noDelay: bool

Whether the socket disables Nagle's algorithm.

Field pollIntervalNanoseconds

pub pollIntervalNanoseconds: u64

Native readiness polling interval in nanoseconds.

Field maximumAttempts

pub maximumAttempts: usize

Maximum native connection attempts.

Field deadline

pub deadline: silk/option.Option<silk/system_clock.Instant>

Absolute overall deadline on the active monotonic timeline.

Field handshakeNanoseconds

pub handshakeNanoseconds: u64

Maximum TLS authentication duration in nanoseconds.

Field tls

pub tls: ClientLimits

TLS protocol storage limits.

Field trust

pub trust: TrustLoadLimits

Explicit trust source load bounds.

Field alpn

pub alpn: AlpnPolicy

HTTP-only application protocol negotiation policy.

Associated function Options.defaults

pub fn defaults() -> Options

Returns finite defaults with no overall deadline and optional HTTP/1.1 negotiation.

NativeTransport

pub struct NativeTransport

One affine native HTTP transport that owns its exact socket or TLS connection.

Method NativeTransport.route

pub fn route<'life0>(self: &'life0 NativeTransport) -> NativeRoute

Returns owned immutable route metadata while leaving the transport exclusively inside its session.

NativeRouteProvider

pub struct NativeRouteProvider

One affine plain native provider owned by a routed HTTP scope.

Details

The provider retains the exact socket selected for the route's physical peer. HTTP and raw byte authority share one terminal state so CONNECT transfer cannot duplicate ownership.

Implementation HttpTransport for NativeRouteProvider

impl HttpTransport for NativeRouteProvider

Operation readSomeRaw

readSomeRaw = NativeRouteProvider.readHttp

Operation writeSomeRaw

writeSomeRaw = NativeRouteProvider.writeHttp

Operation flush

flush = NativeRouteProvider.flushHttp

Operation close

close = NativeRouteProvider.closeHttp

Implementation ByteDuplex for NativeRouteProvider

impl ByteDuplex for NativeRouteProvider

Operation readSomeRaw

readSomeRaw = NativeRouteProvider.readBytes

Operation writeSomeRaw

writeSomeRaw = NativeRouteProvider.writeBytes

Operation flushRaw

flushRaw = NativeRouteProvider.flushBytes

Operation shutdownWriteRaw

shutdownWriteRaw = NativeRouteProvider.shutdownBytes

Operation closeRaw

closeRaw = NativeRouteProvider.closeBytes

acquireOwned

pub effect<'static> fn acquireOwned(origin: Origin, options: Options, limits: Limits, preparedTrust: silk/option.Option<silk/trust_snapshot.TrustSnapshot>, acquisitionDeadline: silk/option.Option<silk/system_clock.Instant>) -> silk/http_client.Connection<silk/http_client_native.NativeTransport> ! NativeClientError | ClientError | ResolverError | NativeSocketError | ConnectionError | IdentityError | OutOfMemoryError ? &mut Allocator | &mut MonotonicClock | &mut SystemClock | &mut Random

Acquires and publishes one complete direct TCP or HTTPS HTTP connection owner.

Details

acquisitionDeadline can only shorten options.deadline. HTTPS consumes one caller-prepared frozen trust snapshot and authenticates the exact original origin. The returned HTTP owner retains no acquisition or request deadline; callers must close it or transfer it into another scoped owner.

Gotchas

On unsupported targets or no-libc profiles, a reached call produces a compile-time error.

admitUnixRoute

pub effect<'life0> fn admitUnixRoute<'life0>(path: &'life0 [u8]) -> NativeRoute ! NativeSocketError

Copies one Unix path into bounded native route metadata before transport contact.

Details

The target-specific native address capacity is checked before the returned route is published.

Gotchas

On unsupported targets or no-libc profiles, a reached call produces a compile-time error.

acquireUnixOwned

pub effect<'life0> fn acquireUnixOwned<'life0>(path: &'life0 [u8], origin: Origin, options: Options, limits: Limits, preparedTrust: silk/option.Option<silk/trust_snapshot.TrustSnapshot>, acquisitionDeadline: silk/option.Option<silk/system_clock.Instant>) -> silk/http_client.Connection<silk/http_client_native.NativeTransport> ! NativeClientError | ClientError | NativeSocketError | ConnectionError | IdentityError | OutOfMemoryError ? &mut Allocator | &mut MonotonicClock | &mut SystemClock | &mut Random

Acquires and publishes one complete Unix-routed HTTP or HTTPS connection owner.

Details

The Unix path selects only the physical transport. TLS still authenticates origin, and the returned HTTP owner retains neither the acquisition nor request deadline.

Gotchas

On unsupported targets or no-libc profiles, a reached call produces a compile-time error.

withConnection

pub effect<'env> fn withConnection<A, E, ?R, H: 'env, 'env>(origin: Origin, options: Options, limits: Limits, handler: H) -> A ! E | ClientError | NativeClientError | ResolverError | NativeSocketError | ConnectionError | IdentityError | TrustSourceError | OutOfMemoryError ? R | &mut Allocator | &mut MonotonicClock | &mut SystemClock | &mut Random | &mut TrustSource where R in Without<R, &HttpTransport>

Resolves and acquires one origin, then lends its serial HTTP connection to one handler.

Details

HTTPS freezes trust before opening and authenticates the original origin. Host fields never replace that identity. Http10 disables ALPN; other policies offer only HTTP/1.1.

Gotchas

On unsupported targets or no-libc profiles, a reached call produces a compile-time error.

withUnixConnection

pub effect<'env> fn withUnixConnection<A, E, ?R, H: 'env, 'env, 'life5: 'env>(path: &'life5 [u8], origin: Origin, options: Options, limits: Limits, handler: H) -> A ! E | ClientError | NativeClientError | NativeSocketError | ConnectionError | IdentityError | TrustSourceError | OutOfMemoryError ? R | &mut Allocator | &mut MonotonicClock | &mut SystemClock | &mut Random | &mut TrustSource where R in Without<R, &HttpTransport>

Connects an explicit Unix socket while retaining a separate HTTP and TLS authority.

Details

The socket path selects only the transport. HTTPS authenticates origin with explicit trust.

Gotchas

On unsupported targets or no-libc profiles, a reached call produces a compile-time error.

withProxyRoute

pub effect<'env> fn withProxyRoute<'configuration: 'env, A, E, ?R, H: 'env, 'env>(route: silk/http_proxy.Route<'configuration>, options: Options, limits: Limits, preparedTrust: silk/option.Option<silk/trust_snapshot.TrustSnapshot>, handler: H) -> A ! E | ProxyError | ClientError | NativeClientError | ResolverError | NativeSocketError | ConnectionError | IdentityError | OutOfMemoryError ? R | &mut Allocator | &mut MonotonicClock | &mut SystemClock | &mut Random where R in Without<R, &ByteDuplex>, R in Without<R, &HttpTransport>

Resolves and connects only one sealed route's physical peer, then lends the final HTTP scope.

Details

options.deadline is passed unchanged through native preflight, resolution, connection, CONNECT, and TLS. limits supplies both the HTTP scope and generated CONNECT bounds. Secure routes consume caller-prepared trust; no resolver fallback or alternate endpoint is selected.

Gotchas

On unsupported targets or no-libc profiles, a reached call produces a compile-time error.

Implementation HttpTransport for NativeTransport

impl HttpTransport for NativeTransport

Operation readSomeRaw

readSomeRaw = NativeTransport.read

Operation writeSomeRaw

writeSomeRaw = NativeTransport.write

Operation flush

flush = NativeTransport.flushOutput

Operation close

close = NativeTransport.closeLease

preflight

pub fn preflight<'life0, 'life1>(origin: &'life0 silk/http_origin.Origin, options: &'life1 silk/http_client_native.Options) -> silk/result.Result<(), silk/http_client_native.NativeClientError>

Checks native TCP support and rejects a hostname deadline before resolver dispatch.

Gotchas

On unsupported targets or no-libc profiles, a reached call produces a compile-time error.

preflightProxyRoute

pub fn preflightProxyRoute<'configuration, 'life1, 'life2>(route: &'life1 silk/http_proxy.Route<'configuration>, options: &'life2 silk/http_client_native.Options) -> silk/result.Result<silk/http_origin.Origin, silk/http_client_native.NativeClientError | silk/http_proxy.ProxyError>

Returns the exact route-selected native peer after target and deadline preflight.

Details

Direct returns the original origin; Forward and Tunnel return the sealed plain proxy origin. A finite deadline with either selected domain fails before synchronous resolver dispatch.

Gotchas

On unsupported targets or no-libc profiles, a reached call produces a compile-time error.

NativeRedirectClient

pub struct NativeRedirectClient<'configuration, 'policy, A, HandlerError, ?HandlerRequirements>

Rebuildable native route acquisition for bounded redirect operations.

Details

The initial sealed route retains the immutable proxy configuration. On supported native targets, every attempt recomputes policy for its current URI, completes method, target, header, and native-route preflight before destination contact, and replaces the stored option deadline with the operation's unchanged absolute deadline. Secure attempts load a fresh trust snapshot before acquisition; tunneled TLS continues to authenticate the original origin through withProxyRoute. On unsupported targets or no-libc profiles, reached acquisition produces a compile-time error.

Associated function NativeRedirectClient.make

pub fn make<'configuration, 'policy, A, HandlerError, ?HandlerRequirements>(route: silk/http_proxy.Route<'configuration>, options: Options, limits: Limits) -> silk/http_client_native.NativeRedirectClient<'configuration, 'policy, A, HandlerError, ? HandlerRequirements>

Creates a reusable redirect attempt client from one policy-selected route.

Gotchas

Construction on unsupported targets or no-libc profiles produces a compile-time error.

Implementation silk/http_redirect.AttemptClient<'policy, silk/http_client_native.NativeRouteProvider, A, HandlerError, silk/allocator.OutOfMemoryError | silk/http.ValueError | silk/http_client.ClientError | silk/http_client_native.NativeClientError | silk/http_origin.OriginError | silk/http_proxy.ProxyError | silk/http_request.RequestError | silk/https_identity.IdentityError | silk/native_socket.NativeSocketError | silk/resolver.ResolverError | silk/tls_connection.ConnectionError | silk/trust_snapshot.TrustSourceError, ? &mut silk/allocator.Allocator | &mut silk/monotonic_clock.MonotonicClock | &mut silk/random.Random | &mut silk/system_clock.SystemClock | &mut silk/trust_source.TrustSource, ? HandlerRequirements> for silk/http_client_native.NativeRedirectClient<'configuration, 'policy, A, HandlerError, ? HandlerRequirements>

impl silk/http_redirect.AttemptClient<'policy, silk/http_client_native.NativeRouteProvider, A, HandlerError, silk/allocator.OutOfMemoryError | silk/http.ValueError | silk/http_client.ClientError | silk/http_client_native.NativeClientError | silk/http_origin.OriginError | silk/http_proxy.ProxyError | silk/http_request.RequestError | silk/https_identity.IdentityError | silk/native_socket.NativeSocketError | silk/resolver.ResolverError | silk/tls_connection.ConnectionError | silk/trust_snapshot.TrustSourceError, ? &mut silk/allocator.Allocator | &mut silk/monotonic_clock.MonotonicClock | &mut silk/random.Random | &mut silk/system_clock.SystemClock | &mut silk/trust_source.TrustSource, ? HandlerRequirements> for silk/http_client_native.NativeRedirectClient<'configuration, 'policy, A, HandlerError, ? HandlerRequirements>

Operation withAttempt

withAttempt = NativeRedirectClient.withAttempt

route

pub fn route<'life0>(connection: &'life0 silk/http_client.Connection<silk/http_client_native.NativeTransport>) -> NativeRoute

Returns immutable native route metadata from an owned HTTP session without lending its transport mutably.

On this page

DetailsGotchasNativeRouteMethod NativeRoute.isUnixMethod NativeRoute.pathImplementation Copy for NativeRouteNativeClientErrorInvalidConnectOptionsUnsupportedDeadlineTrustRequiredAlpnMismatchField errorAlpnPolicyOptionalHttp11RequiredHttp11Http10OptionsField maximumAddressesField familyField noDelayField pollIntervalNanosecondsField maximumAttemptsField deadlineField handshakeNanosecondsField tlsField trustField alpnAssociated function Options.defaultsNativeTransportMethod NativeTransport.routeNativeRouteProviderDetailsImplementation HttpTransport for NativeRouteProviderOperation readSomeRawOperation writeSomeRawOperation flushOperation closeImplementation ByteDuplex for NativeRouteProviderOperation readSomeRawOperation writeSomeRawOperation flushRawOperation shutdownWriteRawOperation closeRawacquireOwnedDetailsGotchasadmitUnixRouteDetailsGotchasacquireUnixOwnedDetailsGotchaswithConnectionDetailsGotchaswithUnixConnectionDetailsGotchaswithProxyRouteDetailsGotchasImplementation HttpTransport for NativeTransportOperation readSomeRawOperation writeSomeRawOperation flushOperation closepreflightGotchaspreflightProxyRouteDetailsGotchasNativeRedirectClientDetailsAssociated function NativeRedirectClient.makeGotchasImplementation silk/http_redirect.AttemptClient<'policy, silk/http_client_native.NativeRouteProvider, A, HandlerError, silk/allocator.OutOfMemoryError | silk/http.ValueError | silk/http_client.ClientError | silk/http_client_native.NativeClientError | silk/http_origin.OriginError | silk/http_proxy.ProxyError | silk/http_request.RequestError | silk/https_identity.IdentityError | silk/native_socket.NativeSocketError | silk/resolver.ResolverError | silk/tls_connection.ConnectionError | silk/trust_snapshot.TrustSourceError, ? &mut silk/allocator.Allocator | &mut silk/monotonic_clock.MonotonicClock | &mut silk/random.Random | &mut silk/system_clock.SystemClock | &mut silk/trust_source.TrustSource, ? HandlerRequirements> for silk/http_client_native.NativeRedirectClient<'configuration, 'policy, A, HandlerError, ? HandlerRequirements>Operation withAttemptroute