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 FramingThe selected body delimiter.
Empty
Framing.Empty: FramingThe message has no payload bytes.
Fixed
Framing.Fixed { length: u64 }: FramingThe payload has one exact declared length.
Field length
pub length: u64The exact payload byte count selected by Content-Length.
Chunked
Framing.Chunked: FramingChunk sizes and delimiters frame the payload.
CloseDelimited
Framing.CloseDelimited: FramingTransport end delimits the payload.
Tunnel
Framing.Tunnel: FramingThe bytes belong to a tunnel rather than an HTTP body.
Implementation Copy for Framing
impl Copy for FramingAnomaly
pub enum AnomalyReceiving metadata that makes an otherwise empty response non-reusable.
None
None = 0No framing anomaly was observed.
ProhibitedFraming
ProhibitedFraming = 1An otherwise empty response contains prohibited framing metadata.
Http10TransferEncoding
Http10TransferEncoding = 2An 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>) -> FramingReturns the selected payload delimiter.
Method Selection.anomaly
pub fn anomaly<'head, 'life1>(self: &'life1 Selection<'head>) -> AnomalyReturns metadata that prevents reuse of an otherwise empty response.
Limits
pub struct LimitsEvery finite framing and owned-storage budget.
Field maxWireBytes
pub maxWireBytes: u64Maximum cumulative wire bytes, including framing syntax.
Field maxPayloadBytes
pub maxPayloadBytes: u64Maximum cumulative payload bytes.
Field maxChunkBytes
pub maxChunkBytes: usizeMaximum payload bytes in one chunk.
Field maxChunks
pub maxChunks: usizeMaximum nonempty chunks in one body.
Field maxChunkLineBytes
pub maxChunkLineBytes: usizeMaximum bytes in one chunk size line.
Field maxExtensionBytes
pub maxExtensionBytes: u64Maximum cumulative chunk extension bytes.
Field maxTrailerBytes
pub maxTrailerBytes: usizeMaximum trailer section bytes.
Field maxTrailerFields
pub maxTrailerFields: usizeMaximum trailer field count.
Field maxOwnedBytes
pub maxOwnedBytes: usizeMaximum bytes retained in owned framing storage.
Field trailerValues
pub trailerValues: ValueLimitsAdmission limits for each retained trailer name and value.
Implementation Copy for Limits
impl Copy for LimitsProgressState
pub enum ProgressStateThe next action required by one incremental body operation.
NeedInput
NeedInput = 0More input is required before progress can continue.
NeedOutput
NeedOutput = 1More output capacity is required before progress can continue.
Complete
Complete = 2The complete framed body has been processed.
Tunnel
Tunnel = 3The bytes belong to a tunnel rather than an HTTP body.
Progress
pub struct ProgressExact local and cumulative committed progress.
Field consumed
pub consumed: usizeInput bytes committed by the current operation.
Field written
pub written: usizeOutput bytes committed by the current operation.
Field totalWire
pub totalWire: u64Cumulative committed wire bytes.
Field totalPayload
pub totalPayload: u64Cumulative committed payload bytes.
Field state
pub state: ProgressStateThe next required action or completed disposition.
CompletionKind
pub enum CompletionKindThe established body-boundary disposition.
Delimited
Delimited = 0The framing establishes an explicit body boundary.
CloseDelimited
CloseDelimited = 1Transport end delimits the payload.
Tunnel
Tunnel = 2The 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>) -> CompletionKindReturns the established body completion disposition.
BodyComponent
pub enum BodyComponentThe framing component responsible for a body failure.
Selection
Selection = 0Body framing selection.
ContentLength
ContentLength = 1Content-Length field admission.
TransferEncoding
TransferEncoding = 2Transfer-Encoding field admission.
ChunkLine
ChunkLine = 3Chunk size and extension syntax.
ChunkPayload
ChunkPayload = 4Chunk payload bytes.
ChunkDelimiter
ChunkDelimiter = 5The delimiter following a chunk payload.
TrailerName
TrailerName = 6Trailer field name admission.
TrailerValue
TrailerValue = 7Trailer field value admission.
TrailerPolicy
TrailerPolicy = 8Trailer name policy admission.
Decoder
Decoder = 9Body decoder state.
Encoder
Encoder = 10Body encoder state.
Discard
Discard = 11Bounded body discard.
BodyLimitKind
pub enum BodyLimitKindThe finite budget exceeded by a body operation.
WireBytes
WireBytes = 0The cumulative wire-byte budget.
PayloadBytes
PayloadBytes = 1The cumulative payload-byte budget.
ChunkBytes
ChunkBytes = 2The per-chunk payload-byte budget.
Chunks
Chunks = 3The nonempty chunk-count budget.
ChunkLineBytes
ChunkLineBytes = 4The chunk-line byte budget.
ExtensionBytes
ExtensionBytes = 5The cumulative extension-byte budget.
TrailerBytes
TrailerBytes = 6The trailer-section byte budget.
TrailerFields
TrailerFields = 7The trailer field-count budget.
TrailerNameBytes
TrailerNameBytes = 8The per-field trailer name-byte budget.
TrailerValueBytes
TrailerValueBytes = 9The per-field trailer value-byte budget.
TrailerFieldBytes
TrailerFieldBytes = 10The combined trailer field-byte budget.
OwnedBytes
OwnedBytes = 11The owned-storage byte budget.
BodyReason
pub union BodyReasonThe reason a body operation cannot continue.
InvalidFraming
BodyReason.InvalidFraming: BodyReasonThe supplied metadata does not admit the requested framing.
ConflictingFraming
BodyReason.ConflictingFraming: BodyReasonThe supplied framing fields disagree.
UnsupportedTransferCoding
BodyReason.UnsupportedTransferCoding: BodyReasonA transfer coding is outside the supported profile.
InvalidLength
BodyReason.InvalidLength: BodyReasonThe declared payload length is invalid.
SizeOverflow
BodyReason.SizeOverflow: BodyReasonSize arithmetic exceeds the representable range.
ChunkSyntax
BodyReason.ChunkSyntax: BodyReasonChunk framing syntax is invalid.
TrailerSyntax
BodyReason.TrailerSyntax: BodyReasonTrailer syntax is invalid.
TrailerPolicy
BodyReason.TrailerPolicy: BodyReasonTrailer name policy admission.
Truncated
BodyReason.Truncated: BodyReasonInput ends before the framed body is complete.
FixedLengthUnderrun
BodyReason.FixedLengthUnderrun: BodyReasonFinalization occurs before the declared payload length is supplied.
FixedLengthOverrun
BodyReason.FixedLengthOverrun: BodyReasonPayload input exceeds the declared length.
UnexpectedPayload
BodyReason.UnexpectedPayload: BodyReasonPayload was supplied for empty framing.
UnsupportedTunnelEncoding
BodyReason.UnsupportedTunnelEncoding: BodyReasonThe encoder cannot encode tunnel bytes as an HTTP body.
DiscardLimit
BodyReason.DiscardLimit { allowed: u64, attempted: u64 }: BodyReasonDiscard would exceed its caller-supplied limit.
Field allowed
pub allowed: u64The admitted maximum for the rejected operation.
Field attempted
pub attempted: u64The count that would exceed the admitted maximum.
LimitExceeded
BodyReason.LimitExceeded { limit: BodyLimitKind, allowed: u64, attempted: u64 }: BodyReasonThe operation would exceed a configured budget.
Field limit
pub limit: BodyLimitKindThe budget exceeded by this operation.
Field allowed
pub allowed: u64The admitted maximum for the rejected operation.
Field attempted
pub attempted: u64The count that would exceed the admitted maximum.
InvalidState
BodyReason.InvalidState: BodyReasonThe operation is not permitted in the current state.
Implementation Copy for BodyReason
impl Copy for BodyReasonBodyError
pub struct BodyErrorA terminal failure with exact committed coordinates.
Field reason
pub reason: BodyReasonThe rule that made the body terminal.
Field component
pub component: BodyComponentThe framing component that rejected the operation.
Field wireOffset
pub wireOffset: u64The zero-based wire byte offset of the failure.
Field consumed
pub consumed: usizeInput bytes committed by the current operation.
Field written
pub written: usizeOutput bytes committed by the current operation.
Field totalWire
pub totalWire: u64Cumulative committed wire bytes.
Field totalPayload
pub totalPayload: u64Cumulative 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 DecoderAffine 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 AllocatorAcquires 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>) -> usizeReturns 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 AllocatorCopies the trailer section into an independent owner under the supplied admission limits.
OwnedTrailers
pub struct OwnedTrailersAn independently owned trailer section.
Method OwnedTrailers.ownedBytes
pub fn ownedBytes<'life0>(self: &'life0 OwnedTrailers) -> usizeReturns 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 EncoderAffine 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 AllocatorAcquires 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.