pub struct UploadBlobParams<'a> {
pub upload_url_template: &'a JmapUrlTemplate,
pub account_id: &'a str,
pub content_type: &'a str,
pub data: Bytes,
}Expand description
Parameters for JmapClient::upload_blob.
Use a struct literal to avoid confusion between the three string-typed
fields (the URL template, the account id, and the content type — three
positional &str arguments are exactly the parameter-confusion footgun
DownloadBlobParams eliminated for the download side):
client.upload_blob(UploadBlobParams {
upload_url_template: &session.upload_url,
account_id: "A13824",
content_type: "application/pdf",
data: bytes::Bytes::from(buffer),
}).await?;Adding an optional per-call timeout override, a body-integrity hint, or any other parameter in a future minor release is a non-breaking minor-version bump — callers who do not set the new field keep working. A positional-arg signature would have locked that future evolution to a major bump (bd:JMAP-6r7c.50).
data is owned (bytes::Bytes) rather than borrowed, because the
HTTP request body takes ownership of the bytes and the Bytes clone
is a cheap refcount bump on the underlying buffer. The other three
fields borrow with a single shared lifetime parameter 'a.
Fields§
§upload_url_template: &'a JmapUrlTemplateURL template from Session.upload_url. {accountId} is the only
template variable substituted before the POST request.
Typed as &JmapUrlTemplate (bd:JMAP-6r7c.40) so the compiler
refuses an accidental &session.api_url (a plain JmapUrl).
account_id: &'a strAccount ID that will own the uploaded blob; substituted for
{accountId} in the URL template.
content_type: &'a strMedia type sent as the HTTP Content-Type request header. Must
be a valid HTTP header value (no CR/LF, no leading/trailing
whitespace) or upload fails with
ClientError::InvalidHeaderValue.
data: BytesRaw bytes to upload. The pre-upload SHA-256 is computed locally
and cross-checked against the server’s BlobUploadResponse.sha256
(when present); the byte length is cross-checked against the
server’s BlobUploadResponse.size.
Trait Implementations§
Source§impl<'a> Clone for UploadBlobParams<'a>
impl<'a> Clone for UploadBlobParams<'a>
Source§fn clone(&self) -> UploadBlobParams<'a>
fn clone(&self) -> UploadBlobParams<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more