silk/http_headers
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.
Ordered, bounded HTTP fields with borrowed iteration and explicit owned copies.
When to use
Use Headers.make over validated borrowed fields, or Headers.copy when the collection must
outlive its source. Lookup is ASCII case-insensitive and never combines repeated values.
Details
Owned collections store payload bytes plus offsets rather than self-references. Formatting emits
only name: value\r\n field lines and is mutation-atomic when caller output is too small.
Import as Headers with import silk.http_headers { Headers }.
Public declarations: 6.
Limits
pub struct LimitsExplicit finite limits for HTTP values, fields, and owned storage.
Field maxMethodBytes
pub maxMethodBytes: usizeMaximum method bytes.
Field maxTargetBytes
pub maxTargetBytes: usizeMaximum request-target bytes.
Field maxNameBytes
pub maxNameBytes: usizeMaximum field-name bytes.
Field maxValueBytes
pub maxValueBytes: usizeMaximum field-value and reason bytes.
Field maxFields
pub maxFields: usizeMaximum fields in a collection.
Field maxFieldBytes
pub maxFieldBytes: usizeMaximum aggregate name-plus-value bytes.
Field maxOwnedBytes
pub maxOwnedBytes: usizeMaximum owned payload capacities plus index storage bytes.
Implementation Copy for Limits
impl Copy for LimitsHeaders
pub struct Headers<'value>An ordered borrowed collection of validated HTTP fields.
Associated function Headers.make
pub fn make<'value>(entries: &'value [silk/http.Header<'value>], limits: Limits) -> silk/result.Result<silk/http_headers.Headers<'value>, silk/http.ValueError>Validates collection budgets and borrows an existing field slice without allocating.
Method Headers.count
pub fn count<'value, 'life1>(self: &'life1 Headers<'value>) -> usizeReturns the number of fields, including duplicates.
Method Headers.fieldBytes
pub fn fieldBytes<'value, 'life1>(self: &'life1 Headers<'value>) -> usizeReturns aggregate field-name plus field-value bytes.
Method Headers.iter
pub fn iter<'value, 'life1>(self: &'life1 Headers<'value>) -> silk/http_headers.HeaderIterator<'value>Iterates every field in insertion order.
Method Headers.getAll
pub fn getAll<'value, 'life1>(self: &'life1 Headers<'value>, name: string<'value>) -> silk/http_headers.HeaderIterator<'value>Iterates every field whose name matches name ASCII case-insensitively.
Method Headers.getFirst
pub fn getFirst<'value, 'life1, 'life2>(self: &'life1 Headers<'value>, name: string<'life2>) -> silk/option.Option<silk/http.Header<'value>>Returns the first matching field without combining duplicates.
Method Headers.getUnique
pub fn getUnique<'value, 'life1, 'life2>(self: &'life1 Headers<'value>, name: string<'life2>) -> silk/result.Result<silk/option.Option<silk/http.Header<'value>>, silk/http.ValueError>Returns an absent or unique matching field and rejects a second match.
Method Headers.copy
pub effect<'env> fn copy<'value: 'env, 'life1: 'env, 'env>(self: &'life1 Headers<'value>, limits: Limits) -> silk/result.Result<silk/http_headers.OwnedHeaders, silk/http.ValueError> ! OutOfMemoryError ? &mut AllocatorCopies fields into independent byte and index storage under maxOwnedBytes.
Method Headers.copyMatching
pub effect<'env> fn copyMatching<'value: 'env, 'life1: 'env, 'env>(self: &'life1 Headers<'value>, name: string<'value>, limits: Limits) -> silk/result.Result<silk/http_headers.OwnedHeaders, silk/http.ValueError> ! OutOfMemoryError ? &mut AllocatorCopies only case-insensitively matching fields in their original order.
Details
All selected-field and owned-capacity limits are checked before allocation. Duplicate fields remain distinct and retain their original relative order.
Method Headers.requiredOwnedBytes
pub fn requiredOwnedBytes<'value, 'life1>(self: &'life1 Headers<'value>) -> silk/result.Result<usize, silk/http.ValueError>Computes the payload-plus-index bytes required by an owned copy without allocating.
Method Headers.formatInto
pub fn formatInto<'value, 'life1, 'life2>(self: &'life1 Headers<'value>, output: &'life2 mut [u8]) -> silk/result.Result<usize, silk/http.ValueError>Formats only ordered field lines into caller storage after a complete sizing pass.
Method Headers.connectionTokens
pub fn connectionTokens<'value, 'life1>(self: &'life1 Headers<'value>) -> silk/http_headers.MetadataIterator<'value>Iterates Connection field tokens while retaining extension spelling.
Method Headers.contentCodings
pub fn contentCodings<'value, 'life1>(self: &'life1 Headers<'value>) -> silk/http_headers.MetadataIterator<'value>Iterates Content-Encoding codings while retaining extensions.
Method Headers.transferCodings
pub fn transferCodings<'value, 'life1>(self: &'life1 Headers<'value>) -> silk/http_headers.MetadataIterator<'value>Iterates Transfer-Encoding codings and validates transfer parameters.
Implementation Copy for silk/http_headers.Headers<'value>
impl Copy for silk/http_headers.Headers<'value>OwnedHeaders
pub struct OwnedHeadersIndependently owned HTTP field payloads and offset records.
Method OwnedHeaders.view
pub fn view<'value>(self: &'value OwnedHeaders) -> silk/http_headers.Headers<'value>Borrows an ordered collection view tied to this owner.
Method OwnedHeaders.ownedBytes
pub fn ownedBytes<'life0>(self: &'life0 OwnedHeaders) -> usizeReturns accounted payload-capacity plus record-storage bytes.
HeaderIterator
pub struct HeaderIterator<'value>An insertion-order iterator over all fields or one case-insensitive name.
Method HeaderIterator.next
pub fn next<'value, 'life1>(self: &'life1 mut HeaderIterator<'value>) -> silk/option.Option<silk/http.Header<'value>>Returns the next matching field, preserving original name and value bytes.
Method HeaderIterator.fieldIndex
pub fn fieldIndex<'value, 'life1>(self: &'life1 HeaderIterator<'value>) -> usizeReturns the source field index of the last yielded entry.
MetadataToken
pub struct MetadataToken<'value>One parsed metadata token borrowed from its source field.
Method MetadataToken.token
pub fn token<'value, 'life1>(self: &'life1 MetadataToken<'value>) -> &'value [u8]Borrows the coding or connection-option token without parameters.
Method MetadataToken.raw
pub fn raw<'value, 'life1>(self: &'life1 MetadataToken<'value>) -> &'value [u8]Borrows the complete list member, including validated transfer parameters.
Method MetadataToken.fieldIndex
pub fn fieldIndex<'value, 'life1>(self: &'life1 MetadataToken<'value>) -> usizeReturns the source collection field index.
Method MetadataToken.offset
pub fn offset<'value, 'life1>(self: &'life1 MetadataToken<'value>) -> usizeReturns the token's byte offset within the source field value.
Method MetadataToken.matches
pub fn matches<'value, 'life1, 'life2>(self: &'life1 MetadataToken<'value>, known: string<'life2>) -> boolRecognizes a known token ASCII case-insensitively without erasing extensions.
Implementation Copy for silk/http_headers.MetadataToken<'value>
impl Copy for silk/http_headers.MetadataToken<'value>MetadataIterator
pub struct MetadataIterator<'value>A lazy ordered iterator over selected HTTP metadata fields.
Method MetadataIterator.next
pub fn next<'value, 'life1>(self: &'life1 mut MetadataIterator<'value>) -> silk/result.Result<silk/option.Option<silk/http_headers.MetadataToken<'value>>, silk/http.ValueError>Parses and returns the next metadata token or a located grammar failure.