Skip to main content

TransferBuilder

Struct TransferBuilder 

Source
pub struct TransferBuilder<'a, E> { /* private fields */ }
Expand description

Builds a streaming transfer. Obtained from Cx::upload / Cx::download; finished with start, which subscribes and returns the key.

Implementations§

Source§

impl<'a, E> TransferBuilder<'a, E>

Source

pub fn method(self, m: impl Into<String>) -> Self

Override the upload method (default PUT). No effect on download.

Source

pub fn multipart(self, field: impl Into<String>) -> Self

Send as multipart/form-data: the file becomes a part named field, emitted after any text field()s. Flips the default method to POST (an explicit method() wins). Upload-only.

Source

pub fn field(self, name: impl Into<String>, value: impl Into<String>) -> Self

Add a text field to the multipart body (order preserved). No effect unless multipart() was called; no effect on download.

Source

pub fn filename(self, name: impl Into<String>) -> Self

Override the multipart file part’s filename= (default: inferred from the source).

Source

pub fn file_content_type(self, ct: impl Into<String>) -> Self

Override the multipart file part’s Content-Type (default: application/octet-stream).

Honored on iOS and Android. On the web shell the browser derives the part’s content type from the Blob’s own MIME type, so this override is native-only in v1.

Source

pub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self

Add a request header (order preserved, repeats allowed).

Source

pub fn bearer(self, token: impl AsRef<str>) -> Self

Sugar for header("Authorization", format!("Bearer {token}")).

Source

pub fn start( self, key: impl Into<String>, on_event: impl Fn(TransferEvent) -> E + Send + 'static, ) -> String

Subscribe under key. on_event fires per progress tick and once at Done. Returns key so the caller can cx.unsubscribe(key).

Auto Trait Implementations§

§

impl<'a, E> !RefUnwindSafe for TransferBuilder<'a, E>

§

impl<'a, E> !Sync for TransferBuilder<'a, E>

§

impl<'a, E> !UnwindSafe for TransferBuilder<'a, E>

§

impl<'a, E> Freeze for TransferBuilder<'a, E>
where &'a mut Cx<E>: Freeze,

§

impl<'a, E> Send for TransferBuilder<'a, E>
where &'a mut Cx<E>: Send,

§

impl<'a, E> Unpin for TransferBuilder<'a, E>
where &'a mut Cx<E>: Unpin,

§

impl<'a, E> UnsafeUnpin for TransferBuilder<'a, E>
where &'a mut Cx<E>: UnsafeUnpin,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.