StreamUploader

Struct StreamUploader 

Source
pub struct StreamUploader<'a, R: 'static + Read + Send + Sync, B = Body> { /* private fields */ }
Expand description

Client implementation to upload streams (file-like objects) and videos via the Wistia Upload API.

Also check out the rust-wistia docs for usage and examples.

Implementations§

Source§

impl<'a> StreamUploader<'a, Cursor<Bytes>>

Source

pub async fn with_url(url: &str) -> Result<StreamUploader<'a, Cursor<Bytes>>>

Create a new StreamUploader which uses the bytes content downloaded from a publicly accessible url.

§Arguments
  • url - A public accessible url to the media which will be downloaded.
§Examples
use rust_wistia::{StreamUploader, https::get_https_client};

let mut uploader = StreamUploader::with_url("https://google.com/my/image").await?;
Source

pub async fn with_url_and_token( url: &str, access_token: &str, ) -> Result<StreamUploader<'a, Cursor<Bytes>>>

Create a new StreamUploader which uses the bytes content downloaded from a publicly accessible url.

§Arguments
  • url - A public accessible url to the media which will be downloaded.
  • access_token - An API access token used to make requests to the Wistia API.
§Examples
use rust_wistia::{StreamUploader, https::get_https_client};

let mut uploader = StreamUploader::with_url_and_token(
    "https://google.com/my/image",
    "my-token"
)
.await?;
Source

pub async fn with_url_and_client( url: &str, client: impl Into<Option<Client<HttpsConnector<HttpConnector>>>>, ) -> Result<StreamUploader<'a, Cursor<Bytes>>>

Create a new StreamUploader which uses the bytes content downloaded from a publicly accessible url.

§Arguments
  • url - A public accessible url to the media which will be downloaded.
  • client - An optional HTTPS client to use for downloading the media.
§Examples
use rust_wistia::{StreamUploader, https::get_https_client};

let client = get_https_client();
let mut uploader = StreamUploader::with_url_and_client("https://google.com/my/image", client).await?;
Source

pub async fn with_url_and_arc_client( url: &str, client: Arc<Client<HttpsConnector<HttpConnector>>>, ) -> Result<StreamUploader<'a, Cursor<Bytes>>>

Create a new StreamUploader which uses the bytes content downloaded from a publicly accessible url.

§Arguments
  • url - A public accessible url to the media which will be downloaded.
  • client - An optional HTTPS client to use for downloading the media.
§Examples
use std::sync::Arc;
use rust_wistia::{StreamUploader, https::get_https_client};

let client = Arc::new(get_https_client());
let mut uploader = StreamUploader::with_url_and_arc_client("https://google.com/my/image", client).await?;
Source§

impl<'a, R: 'static + Read + Send + Sync> StreamUploader<'a, R>

Source

pub fn new(stream: R) -> Result<Self>

Create a StreamUploader with a new HTTPS client, with the access token retrieved from the environment.

§Arguments
  • stream - A readable file-like stream object to upload.
§Examples
use rust_wistia::StreamUploader;
use std::io::Cursor;

let bytes = Cursor::new("Hello World!");
let uploader = StreamUploader::new(bytes)?;

let res = uploader.name("My Video Name").send()?.await?;
Source

pub fn with_stream_and_filename(stream: R, file_name: &'a str) -> Result<Self>

Create a SteamUploader with a new HTTPS client, with the access token retrieved from the environment.

§Arguments
  • stream - A readable file-like stream object to upload.
  • file_name - The name of the media file.
§Examples
use rust_wistia::StreamUploader;
use std::io::Cursor;

let bytes = Cursor::new("Hello World!");
let uploader = StreamUploader::with_stream_and_filename(bytes, "my_file.mp4")?;

let res = uploader.send()?.await?;
Source

pub fn with_filename(file_name: &'a str) -> Result<Self>

Create a SteamUploader with a new HTTPS client, with the access token retrieved from the environment.

§Arguments
  • file_name - The name of the media file.
§Examples
use rust_wistia::StreamUploader;
use std::io::Cursor;

let bytes = Cursor::new("Hello World!");
let uploader = StreamUploader::with_filename("my_file.mp4")?.stream(bytes);

let res = uploader.send()?.await?;
Source

pub fn with_token(access_token: &str) -> Self

Create a SteamUploader with a new HTTPS client and a Wistia access token.

§Arguments
  • access_token - An API access token used to make requests to the Wistia API.
§Examples
use rust_wistia::StreamUploader;
use std::io::Cursor;

let bytes = Cursor::new("Hello World!");
let uploader = StreamUploader::with_token("my-token").stream(bytes);

let res = uploader.send()?.await?;
Source

pub fn with_client(client: UploadClient<Body>) -> Self

Create a SteamUploader with a file path and an HTTPS client.

§Arguments
  • client - The HTTPS client (UploadClient) to use for requests. Note that the client must support multipart form requests, via a multipart::Body.
§Examples
use rust_wistia::{StreamUploader, UploadClient};
use std::io::Cursor;

let client = UploadClient::from_env()?;
let bytes = Cursor::new("Hello World!");
let uploader = StreamUploader::with_client(client).stream(bytes);

let res = uploader.send()?.await?;
Source

pub fn stream(self, stream: R) -> Self

Sets the reader stream which will be used to upload to Wistia.

§Examples
use std::io::Cursor;

let bytes = Cursor::new("Hello World!");
let uploader = rust_wistia::StreamUploader::with_filename("my_file.mp4")?.stream(bytes);
Source

pub fn project_id(self, project_id: &'a str) -> Self

The hashed id of the project to upload media into. If omitted, a new project will be created and uploaded to. The naming convention used for such projects is Uploads_YYYY-MM-DD.

Source

pub fn name(self, name: &'a str) -> Self

A display name to use for the media in Wistia. If omitted, the filename will be used instead. This field is limited to 255 characters.

Source

pub fn description(self, description: &'a str) -> Self

A description to use for the media in Wistia. You can use basic HTML here, but note that both HTML and CSS will be sanitized.

Source

pub fn contact_id(self, contact_id: &'a str) -> Self

A Wistia contact id, an integer value. If omitted, it will default to the contact_id of the account’s owner.

Source

pub async fn send(self) -> Result<UploadResponse>

Send the Upload File request (with the multi-part form data) to the Wistia Upload API.

Trait Implementations§

Source§

impl<'a, R: Clone + 'static + Read + Send + Sync, B: Clone> Clone for StreamUploader<'a, R, B>

Source§

fn clone(&self) -> StreamUploader<'a, R, B>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<'a, R, B> Freeze for StreamUploader<'a, R, B>
where R: Freeze,

§

impl<'a, R, B = Body> !RefUnwindSafe for StreamUploader<'a, R, B>

§

impl<'a, R, B> Send for StreamUploader<'a, R, B>
where B: Send,

§

impl<'a, R, B> Sync for StreamUploader<'a, R, B>
where B: Send,

§

impl<'a, R, B> Unpin for StreamUploader<'a, R, B>
where R: Unpin,

§

impl<'a, R, B = Body> !UnwindSafe for StreamUploader<'a, R, B>

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