Module Runtime.Request_body

type 'a io = 'a t
type t = request_body

Runtime-owned request body value.

type writer = request_body_writer

Scoped request-body writer passed only to of_stream callbacks.

val empty : t

Empty replayable body.

val of_string : string -> t

Replayable body backed by a string.

val of_bytes : bytes -> t

Replayable body backed by bytes.

val of_stream : Awskit.Body.Request.descriptor -> write:(writer -> (unit, Awskit.Error.t) Stdlib.result io) -> t

Streaming body backed by a writer callback.

The descriptor must accurately describe the stream. Mark the body as replayable only if calling write again sends the same bytes. Runtime adapters may call write once per retry attempt, and may cancel it when the request attempt is abandoned or times out.

val descriptor : t -> Awskit.Body.Request.descriptor

Return the signing and retry metadata for a request body.

val content_length : t -> int64 option

Return the declared body length, when known.

val write_string : writer -> string -> (unit, Awskit.Error.t) Stdlib.result io

Write a chunk to a streaming request body. The writer is valid only during the of_stream callback invocation.

val write_bytes : writer -> bytes -> (unit, Awskit.Error.t) Stdlib.result io

Write a bytes chunk to a streaming request body. The writer is valid only during the of_stream callback invocation.

val write_subbytes : writer -> bytes -> off:int -> len:int -> (unit, Awskit.Error.t) Stdlib.result io

Write a bounded bytes slice to a streaming request body. Invalid bounds return Error Body.