Skip to main content

UploadBlobParams

Struct UploadBlobParams 

Source
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 JmapUrlTemplate

URL 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 str

Account ID that will own the uploaded blob; substituted for {accountId} in the URL template.

§content_type: &'a str

Media 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: Bytes

Raw 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>

Source§

fn clone(&self) -> UploadBlobParams<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for UploadBlobParams<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for UploadBlobParams<'a>

§

impl<'a> RefUnwindSafe for UploadBlobParams<'a>

§

impl<'a> Send for UploadBlobParams<'a>

§

impl<'a> Sync for UploadBlobParams<'a>

§

impl<'a> Unpin for UploadBlobParams<'a>

§

impl<'a> UnsafeUnpin for UploadBlobParams<'a>

§

impl<'a> UnwindSafe for UploadBlobParams<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more