Silk

silk/http_body

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.

Strict bounded HTTP/1 message-body framing without transport or content-decoding policy.

Details

Select framing from a validated head, then drive Decoder or Encoder with caller buffers. Construction owns every working allocation. Streaming calls retain no caller borrow and do not allocate. Completion evidence proves only a framing boundary, never transport health.

Import as Decoder with import silk.http_body { Decoder }.

Public declarations: 22.

Framing

pub union Framing

The selected body delimiter.

Empty

Framing.Empty: Framing

The message has no payload bytes.

Fixed

Framing.Fixed { length: u64 }: Framing

The payload has one exact declared length.

Field length

pub length: u64

The exact payload byte count selected by Content-Length.

Chunked

Framing.Chunked: Framing

Chunk sizes and delimiters frame the payload.

CloseDelimited

Framing.CloseDelimited: Framing

Transport end delimits the payload.

Tunnel

Framing.Tunnel: Framing

The bytes belong to a tunnel rather than an HTTP body.

Implementation Copy for Framing

impl Copy for Framing

Anomaly

pub enum Anomaly

Receiving metadata that makes an otherwise empty response non-reusable.

None

None = 0

No framing anomaly was observed.

ProhibitedFraming

ProhibitedFraming = 1

An otherwise empty response contains prohibited framing metadata.

Http10TransferEncoding

Http10TransferEncoding = 2

An HTTP/1.0 message contains transfer-encoding metadata.

Selection

pub struct Selection<'head>

A borrowed framing selection.

Method Selection.framing

pub fn framing<'head, 'life1>(self: &'life1 Selection<'head>) -> Framing

Returns the selected payload delimiter.

Method Selection.anomaly

pub fn anomaly<'head, 'life1>(self: &'life1 Selection<'head>) -> Anomaly

Returns metadata that prevents reuse of an otherwise empty response.

Limits

pub struct Limits

Every finite framing and owned-storage budget.

Field maxWireBytes

pub maxWireBytes: u64

Maximum cumulative wire bytes, including framing syntax.

Field maxPayloadBytes

pub maxPayloadBytes: u64

Maximum cumulative payload bytes.

Field maxChunkBytes

pub maxChunkBytes: usize

Maximum payload bytes in one chunk.

Field maxChunks

pub maxChunks: usize

Maximum nonempty chunks in one body.

Field maxChunkLineBytes

pub maxChunkLineBytes: usize

Maximum bytes in one chunk size line.

Field maxExtensionBytes

pub maxExtensionBytes: u64

Maximum cumulative chunk extension bytes.

Field maxTrailerBytes

pub maxTrailerBytes: usize

Maximum trailer section bytes.

Field maxTrailerFields

pub maxTrailerFields: usize

Maximum trailer field count.

Field maxOwnedBytes

pub maxOwnedBytes: usize

Maximum bytes retained in owned framing storage.

Field trailerValues

pub trailerValues: ValueLimits

Admission limits for each retained trailer name and value.

Implementation Copy for Limits

impl Copy for Limits

ProgressState

pub enum ProgressState

The next action required by one incremental body operation.

NeedInput

NeedInput = 0

More input is required before progress can continue.

NeedOutput

NeedOutput = 1

More output capacity is required before progress can continue.

Complete

Complete = 2

The complete framed body has been processed.

Tunnel

Tunnel = 3

The bytes belong to a tunnel rather than an HTTP body.

Progress

pub struct Progress

Exact local and cumulative committed progress.

Field consumed

pub consumed: usize

Input bytes committed by the current operation.

Field written

pub written: usize

Output bytes committed by the current operation.

Field totalWire

pub totalWire: u64

Cumulative committed wire bytes.

Field totalPayload

pub totalPayload: u64

Cumulative committed payload bytes.

Field state

pub state: ProgressState

The next required action or completed disposition.

CompletionKind

pub enum CompletionKind

The established body-boundary disposition.

Delimited

Delimited = 0

The framing establishes an explicit body boundary.

CloseDelimited

CloseDelimited = 1

Transport end delimits the payload.

Tunnel

Tunnel = 2

The bytes belong to a tunnel rather than an HTTP body.

Completion

pub struct Completion<'owner>

Opaque positive evidence borrowed from a completed owner.

Method Completion.kind

pub fn kind<'owner, 'life1>(self: &'life1 Completion<'owner>) -> CompletionKind

Returns the established body completion disposition.

BodyComponent

pub enum BodyComponent

The framing component responsible for a body failure.

Selection

Selection = 0

Body framing selection.

ContentLength

ContentLength = 1

Content-Length field admission.

TransferEncoding

TransferEncoding = 2

Transfer-Encoding field admission.

ChunkLine

ChunkLine = 3

Chunk size and extension syntax.

ChunkPayload

ChunkPayload = 4

Chunk payload bytes.

ChunkDelimiter

ChunkDelimiter = 5

The delimiter following a chunk payload.

TrailerName

TrailerName = 6

Trailer field name admission.

TrailerValue

TrailerValue = 7

Trailer field value admission.

TrailerPolicy

TrailerPolicy = 8

Trailer name policy admission.

Decoder

Decoder = 9

Body decoder state.

Encoder

Encoder = 10

Body encoder state.

Discard

Discard = 11

Bounded body discard.

BodyLimitKind

pub enum BodyLimitKind

The finite budget exceeded by a body operation.

WireBytes

WireBytes = 0

The cumulative wire-byte budget.

PayloadBytes

PayloadBytes = 1

The cumulative payload-byte budget.

ChunkBytes

ChunkBytes = 2

The per-chunk payload-byte budget.

Chunks

Chunks = 3

The nonempty chunk-count budget.

ChunkLineBytes

ChunkLineBytes = 4

The chunk-line byte budget.

ExtensionBytes

ExtensionBytes = 5

The cumulative extension-byte budget.

TrailerBytes

TrailerBytes = 6

The trailer-section byte budget.

TrailerFields

TrailerFields = 7

The trailer field-count budget.

TrailerNameBytes

TrailerNameBytes = 8

The per-field trailer name-byte budget.

TrailerValueBytes

TrailerValueBytes = 9

The per-field trailer value-byte budget.

TrailerFieldBytes

TrailerFieldBytes = 10

The combined trailer field-byte budget.

OwnedBytes

OwnedBytes = 11

The owned-storage byte budget.

BodyReason

pub union BodyReason

The reason a body operation cannot continue.

InvalidFraming

BodyReason.InvalidFraming: BodyReason

The supplied metadata does not admit the requested framing.

ConflictingFraming

BodyReason.ConflictingFraming: BodyReason

The supplied framing fields disagree.

UnsupportedTransferCoding

BodyReason.UnsupportedTransferCoding: BodyReason

A transfer coding is outside the supported profile.

InvalidLength

BodyReason.InvalidLength: BodyReason

The declared payload length is invalid.

SizeOverflow

BodyReason.SizeOverflow: BodyReason

Size arithmetic exceeds the representable range.

ChunkSyntax

BodyReason.ChunkSyntax: BodyReason

Chunk framing syntax is invalid.

TrailerSyntax

BodyReason.TrailerSyntax: BodyReason

Trailer syntax is invalid.

TrailerPolicy

BodyReason.TrailerPolicy: BodyReason

Trailer name policy admission.

Truncated

BodyReason.Truncated: BodyReason

Input ends before the framed body is complete.

FixedLengthUnderrun

BodyReason.FixedLengthUnderrun: BodyReason

Finalization occurs before the declared payload length is supplied.

FixedLengthOverrun

BodyReason.FixedLengthOverrun: BodyReason

Payload input exceeds the declared length.

UnexpectedPayload

BodyReason.UnexpectedPayload: BodyReason

Payload was supplied for empty framing.

UnsupportedTunnelEncoding

BodyReason.UnsupportedTunnelEncoding: BodyReason

The encoder cannot encode tunnel bytes as an HTTP body.

DiscardLimit

BodyReason.DiscardLimit { allowed: u64, attempted: u64 }: BodyReason

Discard would exceed its caller-supplied limit.

Field allowed

pub allowed: u64

The admitted maximum for the rejected operation.

Field attempted

pub attempted: u64

The count that would exceed the admitted maximum.

LimitExceeded

BodyReason.LimitExceeded { limit: BodyLimitKind, allowed: u64, attempted: u64 }: BodyReason

The operation would exceed a configured budget.

Field limit

pub limit: BodyLimitKind

The budget exceeded by this operation.

Field allowed

pub allowed: u64

The admitted maximum for the rejected operation.

Field attempted

pub attempted: u64

The count that would exceed the admitted maximum.

InvalidState

BodyReason.InvalidState: BodyReason

The operation is not permitted in the current state.

Implementation Copy for BodyReason

impl Copy for BodyReason

BodyError

pub struct BodyError

A terminal failure with exact committed coordinates.

Field reason

pub reason: BodyReason

The rule that made the body terminal.

Field component

pub component: BodyComponent

The framing component that rejected the operation.

Field wireOffset

pub wireOffset: u64

The zero-based wire byte offset of the failure.

Field consumed

pub consumed: usize

Input bytes committed by the current operation.

Field written

pub written: usize

Output bytes committed by the current operation.

Field totalWire

pub totalWire: u64

Cumulative committed wire bytes.

Field totalPayload

pub totalPayload: u64

Cumulative committed payload bytes.

Field fieldIndex

pub fieldIndex: silk/option.Option<usize>

The zero-based trailer field index, when the failure identifies one.

TrailerPolicy

pub union TrailerPolicy<'names>

An explicit trailer-name allowlist.

Default

TrailerPolicy<'names>.Default: TrailerPolicy<'names>

Applies the default forbidden-trailer policy.

Explicit

TrailerPolicy<'names>.Explicit { names: &'names [string<'names>] }: TrailerPolicy<'names>

Restricts trailers to the supplied admitted field names.

Associated function TrailerPolicy.defaultPolicy

pub fn defaultPolicy<'names>() -> silk/http_body.TrailerPolicy<'names>

Returns the default forbidden-trailer policy.

Associated function TrailerPolicy.fromNames

pub fn fromNames<'names>(names: &'names [string<'names>]) -> silk/result.Result<silk/http_body.TrailerPolicy<'names>, silk/http_body.BodyError>

Validates an explicit trailer-name allowlist and borrows it without allocation.

Implementation Copy for silk/http_body.TrailerPolicy<'names>

impl Copy for silk/http_body.TrailerPolicy<'names>

selectRequest

pub fn selectRequest<'value, 'life1>(head: silk/http_head.RequestHead<'value>, policy: silk/http_body.TrailerPolicy<'life1>) -> silk/result.Result<silk/http_body.Selection<'value>, silk/http_body.BodyError>

Selects receiving request framing.

selectResponse

pub fn selectResponse<'value, 'life1, 'life2, 'life3>(head: silk/http_head.ResponseHead<'value>, requestMethod: &'life1 silk/http.Method<'life2>, policy: silk/http_body.TrailerPolicy<'life3>) -> silk/result.Result<silk/http_body.Selection<'value>, silk/http_body.BodyError>

Selects receiving response framing.

validateOutgoingRequest

pub fn validateOutgoingRequest<'value, 'life1>(head: silk/http_head.RequestHead<'value>, policy: silk/http_body.TrailerPolicy<'life1>) -> silk/result.Result<silk/http_body.Selection<'value>, silk/http_body.BodyError>

Validates request framing and trailer policy before payload encoding.

validateOutgoingResponse

pub fn validateOutgoingResponse<'value, 'life1, 'life2, 'life3>(head: silk/http_head.ResponseHead<'value>, requestMethod: &'life1 silk/http.Method<'life2>, policy: silk/http_body.TrailerPolicy<'life3>) -> silk/result.Result<silk/http_body.Selection<'value>, silk/http_body.BodyError>

Validates response framing, including status and request-method restrictions, before payload encoding.

Decoder

pub struct Decoder

Affine allocation-free incremental body decoder.

Associated function Decoder.make

pub effect<'env> fn make<'head: 'env, 'life1: 'env, 'env>(selection: silk/http_body.Selection<'head>, limits: Limits, policy: silk/http_body.TrailerPolicy<'life1>) -> silk/result.Result<silk/http_body.Decoder, silk/http_body.BodyError> ! OutOfMemoryError ? &mut Allocator

Acquires every decoder buffer and copies trailer policy and Connection exclusions.

Method Decoder.step

pub fn step<'life0, 'life1, 'life2>(self: &'life0 mut Decoder, input: &'life1 [u8], output: &'life2 mut [u8], finalInput: bool) -> silk/result.Result<silk/http_body.Progress, silk/http_body.BodyError>

Decodes into caller output without consuming unwritten payload.

Method Decoder.discard

pub fn discard<'life0, 'life1>(self: &'life0 mut Decoder, input: &'life1 [u8], finalInput: bool, maxDiscardWireBytes: u64) -> silk/result.Result<silk/http_body.Progress, silk/http_body.BodyError>

Discards wire bytes under an explicit cumulative framing-byte budget.

Method Decoder.completion

pub fn completion<'owner>(self: &'owner Decoder) -> silk/option.Option<silk/http_body.Completion<'owner>>

Returns positive evidence only after a successful terminal boundary.

Method Decoder.trailers

pub fn trailers<'owner>(self: &'owner Decoder) -> silk/option.Option<silk/http_body.Trailers<'owner>>

Returns completed chunk trailers without merging them into initial fields.

Method Decoder.abandon

pub fn abandon<'life0>(self: &'life0 mut Decoder) -> ()

Makes the decoder terminal without performing transport work.

Trailers

pub struct Trailers<'owner>

A decoder-borrowed trailer section.

Method Trailers.count

pub fn count<'owner, 'life1>(self: &'life1 Trailers<'owner>) -> usize

Returns the number of retained trailer fields.

Method Trailers.requiredOwnedBytes

pub fn requiredOwnedBytes<'owner, 'life1>(self: &'life1 Trailers<'owner>) -> silk/result.Result<usize, silk/http_body.BodyError>

Returns the exact payload-plus-index bytes required by an independent owned copy.

Method Trailers.fields

pub fn fields<'owner>(self: &'owner Trailers<'owner>) -> silk/http_body.TrailerIterator<'owner>

Borrows an iterator over trailer fields in their retained order.

Method Trailers.copy

pub effect<'owner> fn copy<'owner>(self: &'owner Trailers<'owner>, limits: ValueLimits) -> silk/result.Result<silk/http_body.OwnedTrailers, silk/http_body.BodyError> ! OutOfMemoryError ? &mut Allocator

Copies the trailer section into an independent owner under the supplied admission limits.

OwnedTrailers

pub struct OwnedTrailers

An independently owned trailer section.

Method OwnedTrailers.ownedBytes

pub fn ownedBytes<'life0>(self: &'life0 OwnedTrailers) -> usize

Returns the exact retained trailer payload-plus-index byte count.

Method OwnedTrailers.view

pub fn view<'owner>(self: &'owner OwnedTrailers) -> silk/http_body.Trailers<'owner>

Borrows a trailer view tied to this owner.

TrailerIterator

pub struct TrailerIterator<'owner>

An ordered iterator borrowing one retained trailer section.

Method TrailerIterator.next

pub fn next<'owner, 'life1>(self: &'life1 mut TrailerIterator<'owner>) -> silk/option.Option<silk/http.Header<'owner>>

Returns the next borrowed trailer field, or None after the final field.

Encoder

pub struct Encoder

Affine allocation-free incremental body encoder.

Associated function Encoder.make

pub effect<'env> fn make<'head: 'env, 'life1: 'env, 'env>(selection: silk/http_body.Selection<'head>, limits: Limits, policy: silk/http_body.TrailerPolicy<'life1>) -> silk/result.Result<silk/http_body.Encoder, silk/http_body.BodyError> ! OutOfMemoryError ? &mut Allocator

Acquires bounded chunk and finish-snapshot storage.

Method Encoder.step

pub fn step<'life0, 'life1, 'life2>(self: &'life0 mut Encoder, input: &'life1 [u8], output: &'life2 mut [u8]) -> silk/result.Result<silk/http_body.Progress, silk/http_body.BodyError>

Accepts payload and emits as much framed output as fits.

Method Encoder.beginFinish

pub fn beginFinish<'value, 'life1, 'life2>(self: &'life1 mut Encoder, trailers: &'life2 silk/http_headers.Headers<'value>) -> silk/result.Result<(), silk/http_body.BodyError>

Validates and snapshots all finish trailers before any finish byte is emitted.

Method Encoder.continueFinish

pub fn continueFinish<'life0, 'life1>(self: &'life0 mut Encoder, output: &'life1 mut [u8]) -> silk/result.Result<silk/http_body.Progress, silk/http_body.BodyError>

Drains the immutable finish snapshot.

Method Encoder.completion

pub fn completion<'owner>(self: &'owner Encoder) -> silk/option.Option<silk/http_body.Completion<'owner>>

Borrows positive completion evidence only after successful encoder finalization.

Method Encoder.abandon

pub fn abandon<'life0>(self: &'life0 mut Encoder) -> ()

Makes an unfinished encoder unusable without emitting additional bytes.

On this page

DetailsFramingEmptyFixedField lengthChunkedCloseDelimitedTunnelImplementation Copy for FramingAnomalyNoneProhibitedFramingHttp10TransferEncodingSelectionMethod Selection.framingMethod Selection.anomalyLimitsField maxWireBytesField maxPayloadBytesField maxChunkBytesField maxChunksField maxChunkLineBytesField maxExtensionBytesField maxTrailerBytesField maxTrailerFieldsField maxOwnedBytesField trailerValuesImplementation Copy for LimitsProgressStateNeedInputNeedOutputCompleteTunnelProgressField consumedField writtenField totalWireField totalPayloadField stateCompletionKindDelimitedCloseDelimitedTunnelCompletionMethod Completion.kindBodyComponentSelectionContentLengthTransferEncodingChunkLineChunkPayloadChunkDelimiterTrailerNameTrailerValueTrailerPolicyDecoderEncoderDiscardBodyLimitKindWireBytesPayloadBytesChunkBytesChunksChunkLineBytesExtensionBytesTrailerBytesTrailerFieldsTrailerNameBytesTrailerValueBytesTrailerFieldBytesOwnedBytesBodyReasonInvalidFramingConflictingFramingUnsupportedTransferCodingInvalidLengthSizeOverflowChunkSyntaxTrailerSyntaxTrailerPolicyTruncatedFixedLengthUnderrunFixedLengthOverrunUnexpectedPayloadUnsupportedTunnelEncodingDiscardLimitField allowedField attemptedLimitExceededField limitField allowedField attemptedInvalidStateImplementation Copy for BodyReasonBodyErrorField reasonField componentField wireOffsetField consumedField writtenField totalWireField totalPayloadField fieldIndexTrailerPolicyDefaultExplicitAssociated function TrailerPolicy.defaultPolicyAssociated function TrailerPolicy.fromNamesImplementation Copy for silk/http_body.TrailerPolicy<'names>selectRequestselectResponsevalidateOutgoingRequestvalidateOutgoingResponseDecoderAssociated function Decoder.makeMethod Decoder.stepMethod Decoder.discardMethod Decoder.completionMethod Decoder.trailersMethod Decoder.abandonTrailersMethod Trailers.countMethod Trailers.requiredOwnedBytesMethod Trailers.fieldsMethod Trailers.copyOwnedTrailersMethod OwnedTrailers.ownedBytesMethod OwnedTrailers.viewTrailerIteratorMethod TrailerIterator.nextEncoderAssociated function Encoder.makeMethod Encoder.stepMethod Encoder.beginFinishMethod Encoder.continueFinishMethod Encoder.completionMethod Encoder.abandon