Skip to main content

TaskRequest

Struct TaskRequest 

Source
pub struct TaskRequest { /* private fields */ }
Expand description

Serialized task request used by job and standalone task APIs.

Most jobs can be built with crate::JobCreateRequest::linear or crate::JobCreateRequest::graph. Use TaskRequest directly for standalone task APIs, explicit low-level job construction, or operations that do not have a first-class typed builder yet.

use cloudconvert_sdk::{FileExtension, JobCreateRequest};

let request = JobCreateRequest::graph(|job| {
    let import = job.import_url("https://example.test/input.docx");
    job.convert(&import, FileExtension::Pdf);
})
.build();

let payload = serde_json::to_value(request).unwrap();
assert_eq!(payload["tasks"]["convert"]["input"], "import-url");

Implementations§

Source§

impl TaskRequest

Source

pub fn import_url(url: impl Into<String>) -> Self

Creates an import/url task request.

Source

pub fn import_upload() -> Self

Creates an import/upload task request.

Source

pub fn import_base64( file: impl Into<String>, filename: impl Into<String>, ) -> Self

Creates an import/base64 task request.

Source

pub fn import_raw(file: impl Into<String>, filename: impl Into<String>) -> Self

Creates an import/raw task request.

Source

pub fn import_s3( bucket: impl Into<String>, region: impl Into<String>, access_key_id: impl Into<String>, secret_access_key: impl Into<String>, ) -> Self

Creates an import/s3 task request.

Source

pub fn import_azure_blob( storage_account: impl Into<String>, container: impl Into<String>, ) -> Self

Creates an import/azure/blob task request.

Source

pub fn import_google_cloud_storage( project_id: impl Into<String>, bucket: impl Into<String>, client_email: impl Into<String>, private_key: impl Into<String>, ) -> Self

Creates an import/google-cloud-storage task request.

Source

pub fn import_openstack( auth_url: impl Into<String>, username: impl Into<String>, password: impl Into<String>, region: impl Into<String>, container: impl Into<String>, ) -> Self

Creates an import/openstack task request.

Source

pub fn import_sftp(host: impl Into<String>, username: impl Into<String>) -> Self

Creates an import/sftp task request.

Source

pub fn convert( input: impl Into<Input>, output_format: impl Into<String>, ) -> Self

Creates a convert task request.

Source

pub fn optimize(input: impl Into<Input>) -> Self

Creates an optimize task request.

Source

pub fn watermark(task: WatermarkTask) -> Self

Creates a watermark task request from a typed watermark task.

Source

pub fn capture_website( url: impl Into<String>, output_format: impl Into<String>, ) -> Self

Creates a capture-website task request.

Source

pub fn thumbnail( input: impl Into<Input>, output_format: impl Into<String>, ) -> Self

Creates a thumbnail task request.

Source

pub fn metadata(input: impl Into<Input>) -> Self

Creates a metadata task request.

Source

pub fn metadata_write(input: impl Into<Input>) -> Self

Creates a metadata/write task request.

Source

pub fn merge(input: impl Into<Input>, output_format: impl Into<String>) -> Self

Creates a merge task request.

Source

pub fn archive( input: impl Into<Input>, output_format: impl Into<String>, ) -> Self

Creates an archive task request.

Source

pub fn command( input: impl Into<Input>, engine: impl Into<String>, command: impl Into<String>, arguments: impl Into<String>, ) -> Self

Creates a command task request.

Source

pub fn pdf_a(input: impl Into<Input>) -> Self

Creates a pdf/a task request.

Source

pub fn pdf_x(input: impl Into<Input>) -> Self

Creates a pdf/x task request.

Source

pub fn pdf_ocr(input: impl Into<Input>) -> Self

Creates a pdf/ocr task request.

Source

pub fn pdf_encrypt(input: impl Into<Input>) -> Self

Creates a pdf/encrypt task request.

Source

pub fn pdf_decrypt(input: impl Into<Input>) -> Self

Creates a pdf/decrypt task request.

Source

pub fn pdf_split_pages(input: impl Into<Input>) -> Self

Creates a pdf/split-pages task request.

Source

pub fn pdf_extract_pages(input: impl Into<Input>) -> Self

Creates a pdf/extract-pages task request.

Source

pub fn pdf_rotate_pages(input: impl Into<Input>) -> Self

Creates a pdf/rotate-pages task request.

Source

pub fn export_url(input: impl Into<Input>) -> Self

Creates an export/url task request.

Source

pub fn export_s3( input: impl Into<Input>, bucket: impl Into<String>, region: impl Into<String>, access_key_id: impl Into<String>, secret_access_key: impl Into<String>, ) -> Self

Creates an export/s3 task request.

Source

pub fn export_azure_blob( input: impl Into<Input>, storage_account: impl Into<String>, container: impl Into<String>, ) -> Self

Creates an export/azure/blob task request.

Source

pub fn export_google_cloud_storage( input: impl Into<Input>, project_id: impl Into<String>, bucket: impl Into<String>, client_email: impl Into<String>, private_key: impl Into<String>, ) -> Self

Creates an export/google-cloud-storage task request.

Source

pub fn export_openstack( input: impl Into<Input>, auth_url: impl Into<String>, username: impl Into<String>, password: impl Into<String>, region: impl Into<String>, container: impl Into<String>, ) -> Self

Creates an export/openstack task request.

Source

pub fn export_sftp( input: impl Into<Input>, host: impl Into<String>, username: impl Into<String>, ) -> Self

Creates an export/sftp task request.

Source

pub fn export_upload(input: impl Into<Input>, url: impl Into<String>) -> Self

Creates an export/upload task request.

Source

pub fn custom(operation: impl Into<String>) -> GenericTask

Starts a custom task request for an operation not typed by the SDK.

use cloudconvert_sdk::TaskRequest;
use serde_json::json;

let task = TaskRequest::custom("custom/op")
    .field("input", "import-file")
    .field("custom_option", json!(true));

assert_eq!(task.operation(), "custom/op");
Source

pub fn try_from_payload<T>(payload: T) -> Result<Self>
where T: TaskPayload,

Converts a typed task payload into a TaskRequest.

Source

pub fn from_payload<T>(payload: T) -> Self
where T: TaskPayload,

Converts a typed task payload into a TaskRequest.

Panics only if an SDK-owned typed task serializes to something other than a JSON object.

Source

pub fn operation(&self) -> &str

Returns the CloudConvert operation name.

Source

pub fn payload(&self) -> &Map<String, Value>

Returns the task payload without the injected operation field.

Trait Implementations§

Source§

impl Clone for TaskRequest

Source§

fn clone(&self) -> TaskRequest

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 Debug for TaskRequest

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<ArchiveTask> for TaskRequest

Source§

fn from(value: ArchiveTask) -> Self

Converts to this type from the input type.
Source§

impl From<AzureBlobExportTask> for TaskRequest

Source§

fn from(value: AzureBlobExportTask) -> Self

Converts to this type from the input type.
Source§

impl From<AzureBlobImportTask> for TaskRequest

Source§

fn from(value: AzureBlobImportTask) -> Self

Converts to this type from the input type.
Source§

impl From<Base64ImportTask> for TaskRequest

Source§

fn from(value: Base64ImportTask) -> Self

Converts to this type from the input type.
Source§

impl From<CaptureWebsiteTask> for TaskRequest

Source§

fn from(value: CaptureWebsiteTask) -> Self

Converts to this type from the input type.
Source§

impl From<CommandTask> for TaskRequest

Source§

fn from(value: CommandTask) -> Self

Converts to this type from the input type.
Source§

impl From<ConvertTask> for TaskRequest

Source§

fn from(value: ConvertTask) -> Self

Converts to this type from the input type.
Source§

impl From<ExportUploadTask> for TaskRequest

Source§

fn from(value: ExportUploadTask) -> Self

Converts to this type from the input type.
Source§

impl From<ExportUrlTask> for TaskRequest

Source§

fn from(value: ExportUrlTask) -> Self

Converts to this type from the input type.
Source§

impl From<GenericTask> for TaskRequest

Source§

fn from(value: GenericTask) -> Self

Converts to this type from the input type.
Source§

impl From<GoogleCloudStorageExportTask> for TaskRequest

Source§

fn from(value: GoogleCloudStorageExportTask) -> Self

Converts to this type from the input type.
Source§

impl From<GoogleCloudStorageImportTask> for TaskRequest

Source§

fn from(value: GoogleCloudStorageImportTask) -> Self

Converts to this type from the input type.
Source§

impl From<ImportUploadTask> for TaskRequest

Source§

fn from(value: ImportUploadTask) -> Self

Converts to this type from the input type.
Source§

impl From<ImportUrlTask> for TaskRequest

Source§

fn from(value: ImportUrlTask) -> Self

Converts to this type from the input type.
Source§

impl From<MergeTask> for TaskRequest

Source§

fn from(value: MergeTask) -> Self

Converts to this type from the input type.
Source§

impl From<MetadataTask> for TaskRequest

Source§

fn from(value: MetadataTask) -> Self

Converts to this type from the input type.
Source§

impl From<MetadataWriteTask> for TaskRequest

Source§

fn from(value: MetadataWriteTask) -> Self

Converts to this type from the input type.
Source§

impl From<OpenStackExportTask> for TaskRequest

Source§

fn from(value: OpenStackExportTask) -> Self

Converts to this type from the input type.
Source§

impl From<OpenStackImportTask> for TaskRequest

Source§

fn from(value: OpenStackImportTask) -> Self

Converts to this type from the input type.
Source§

impl From<OptimizeTask> for TaskRequest

Source§

fn from(value: OptimizeTask) -> Self

Converts to this type from the input type.
Source§

impl From<PdfATask> for TaskRequest

Source§

fn from(value: PdfATask) -> Self

Converts to this type from the input type.
Source§

impl From<PdfDecryptTask> for TaskRequest

Source§

fn from(value: PdfDecryptTask) -> Self

Converts to this type from the input type.
Source§

impl From<PdfEncryptTask> for TaskRequest

Source§

fn from(value: PdfEncryptTask) -> Self

Converts to this type from the input type.
Source§

impl From<PdfExtractPagesTask> for TaskRequest

Source§

fn from(value: PdfExtractPagesTask) -> Self

Converts to this type from the input type.
Source§

impl From<PdfOcrTask> for TaskRequest

Source§

fn from(value: PdfOcrTask) -> Self

Converts to this type from the input type.
Source§

impl From<PdfRotatePagesTask> for TaskRequest

Source§

fn from(value: PdfRotatePagesTask) -> Self

Converts to this type from the input type.
Source§

impl From<PdfSplitPagesTask> for TaskRequest

Source§

fn from(value: PdfSplitPagesTask) -> Self

Converts to this type from the input type.
Source§

impl From<PdfXTask> for TaskRequest

Source§

fn from(value: PdfXTask) -> Self

Converts to this type from the input type.
Source§

impl From<RawImportTask> for TaskRequest

Source§

fn from(value: RawImportTask) -> Self

Converts to this type from the input type.
Source§

impl From<S3ExportTask> for TaskRequest

Source§

fn from(value: S3ExportTask) -> Self

Converts to this type from the input type.
Source§

impl From<S3ImportTask> for TaskRequest

Source§

fn from(value: S3ImportTask) -> Self

Converts to this type from the input type.
Source§

impl From<SftpExportTask> for TaskRequest

Source§

fn from(value: SftpExportTask) -> Self

Converts to this type from the input type.
Source§

impl From<SftpImportTask> for TaskRequest

Source§

fn from(value: SftpImportTask) -> Self

Converts to this type from the input type.
Source§

impl From<ThumbnailTask> for TaskRequest

Source§

fn from(value: ThumbnailTask) -> Self

Converts to this type from the input type.
Source§

impl From<WatermarkTask> for TaskRequest

Source§

fn from(value: WatermarkTask) -> Self

Converts to this type from the input type.
Source§

impl Serialize for TaskRequest

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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