Skip to content

Return a WireRequest that borrows nothing, and read it with its buffer - #54

Open
tiptenbrink wants to merge 2 commits into
ureq-host-clientsfrom
encode-placement
Open

tiptenbrink wants to merge 2 commits into
ureq-host-clientsfrom
encode-placement

Conversation

@tiptenbrink

@tiptenbrink tiptenbrink commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #53. Every function that writes a request now returns a WireRequest that borrows nothing. It holds the method, and where the URL, head, field lines and body are in the buffer. Each part is read by passing that buffer. A host that keeps its buffer can grow it and write a request again without converting anything:

let request = crate::grown_to_fit(&mut self.buf, |buf| {
    azure::encode_get(template, bytes, &item, &now, buf)
})?;
let (parts, body) = crate::send(&self.agent, &request, &self.buf, None)?;

Before, an encoder returned a WireRequest<'r> that borrowed the buffer, and the caller's content. A host that grew its buffer had to add .map(|request| request.placement()) to each call, and turn the Placement back into a request with placement.request(&buf).

What changes

  • WireRequest has no lifetime and is Copy. url(&buf), headers(&buf), head(&buf) and payload(&buf) read its parts from the buffer it was written into. The span accessors (url_span, head_span, fields_span, body_span) stay, with a new content_len.
  • Placement and WireRequest::placement are gone. The C ABI already had only the span struct, borink_wire_request, so the Rust and C types now match.
  • Every azure::encode_*, s3::set_signature and sigv4::sign returns a WireRequest. An S3 encoder still returns an s3::Unsigned, which no longer has a lifetime. Its canonical(&buf) and body(&buf) already read the buffer the same way.
  • A request no longer lends back content passed as Payload::Slice. It states the content's length as Payload::Streamed, and the host sends the bytes it holds. A body that the crate wrote, such as a block list or a list of parts, is still lent from the buffer. A request without content still has an empty Payload::Slice.
  • Passing the wrong buffer gives a wrong request, but never a panic, as before.

Callers

  • The ureq host's send takes the request and its buffer.
  • The object-tests host sends a (WireRequest, &[u8]) pair. It also names each Azure encoder once: one closure sizes the buffer and writes the request.
  • The C ABI converts a WireRequest to its request struct. The C types and the header are unchanged.
  • azure_put's content test now expects held and streamed content to give the same request.

Not in this PR: object-storage.dev's replay and benchmarks, which read WireRequest through the borrowing accessors. They move to the new readers when they next take this crate.

Checked locally: cargo fmt --check, clippy on all targets and features, every workspace test, the docs with -D warnings, and the link check without an allocator.

tiptenbrink and others added 2 commits October 14, 2026 21:03
The encode_* functions, s3::set_signature and sigv4::sign return a Placement, which borrows nothing, and Placement::request reads the WireRequest from the buffer.
A request no longer lends back content passed as Payload::Slice: it states the length, and the host sends the bytes.
s3::Unsigned loses its lifetime, and the span accessors move from WireRequest to Placement.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Placement is gone: every encoder, s3::set_signature and sigv4::sign return a WireRequest of spans, and its url, headers, head and payload take the buffer it was written into.
The hosts pass a request and its buffer together, as the C ABI already does.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@tiptenbrink tiptenbrink changed the title Return a Placement from every encoder, and read requests from it Return a WireRequest that borrows nothing, and read it with its buffer Oct 14, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant