Silk

silk/http_origin

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.

Owned checked HTTP origins, separate from request paths and explicit Host fields.

Details

An origin retains the checked host, effective port, and transport scheme without allocation. Authority output uses lowercase domain bytes, canonical numeric addresses, and nondefault ports. An explicit Host field never changes the origin used for TLS authentication.

Import as Origin with import silk.http_origin { Origin }.

Public declarations: 2.

OriginError

pub enum OriginError

A rejected HTTP origin or insufficient authority output buffer.

InvalidScheme

InvalidScheme = 0

The URI scheme is neither HTTP nor HTTPS.

UserInfo

UserInfo = 1

User information is forbidden in an HTTP origin.

MissingHost

MissingHost = 2

The URI has no host.

InvalidHost

InvalidHost = 3

The host fails the checked network identity rules.

InvalidPort

InvalidPort = 4

The port is empty, nondecimal, or outside 1 through 65535.

OutputTooSmall

OutputTooSmall = 5

Output cannot hold the complete authority.

Origin

pub struct Origin

An owned HTTP authority and secure-transport selection.

Associated function Origin.make

pub fn make(host: Host, port: Port, secure: bool) -> silk/result.Result<silk/http_origin.Origin, silk/http_origin.OriginError>

Checks a host, a nonzero port, and an explicit transport-security selection.

Associated function Origin.fromUri

pub fn fromUri<'life0, 'life1>(uri: &'life0 silk/uri.Uri<'life1>) -> silk/result.Result<silk/http_origin.Origin, silk/http_origin.OriginError>

Checks an HTTP or HTTPS URI and copies its host and effective port without allocation.

Details

User information is rejected. Absent ports become 80 for HTTP and 443 for HTTPS. The path, query, and fragment do not contribute to this origin.

Method Origin.host

pub fn host<'life0>(self: &'life0 Origin) -> Host

Returns the owned checked identity used for resolution and TLS authentication.

Method Origin.port

pub fn port<'life0>(self: &'life0 Origin) -> Port

Returns the effective checked port, including a scheme default.

Method Origin.secure

pub fn secure<'life0>(self: &'life0 Origin) -> bool

Returns whether this origin requires authenticated TLS.

Method Origin.equals

pub fn equals<'life0, 'life1>(self: &'life0 Origin, other: &'life1 Origin) -> bool

Compares transport scheme, effective port, and case-insensitive checked host identity.

Method Origin.authorityInto

pub fn authorityInto<'life0, 'life1>(self: &'life0 Origin, output: &'life1 mut [u8]) -> silk/result.Result<usize, silk/http_origin.OriginError>

Writes the normalized authority and leaves output unchanged when capacity is insufficient.

Method Origin.authorityWithPortInto

pub fn authorityWithPortInto<'life0, 'life1>(self: &'life0 Origin, output: &'life1 mut [u8]) -> silk/result.Result<usize, silk/http_origin.OriginError>

Writes the normalized authority with its effective port, including a default port.

Details

A capacity failure leaves output unchanged.

Method Origin.matchesAuthority

pub fn matchesAuthority<'life0, 'life1>(self: &'life0 Origin, text: string<'life1>) -> bool

Checks an explicit authority against this origin, allowing an explicit default port.

Details

The authority must contain only a checked host and optional decimal port. Case-insensitive domains and equivalent numeric addresses compare equal.

Implementation Copy for Origin

impl Copy for Origin

On this page