Crate tus_async_client

Source
Expand description

§tus_async_client

A Rust native client library to interact with tus enabled endpoints.

§Usage

use tus_async_client::Client;
use reqwest;
use std::rc::Rc;
use std::sync::Arc;

// Create an instance of the `tus_async_client::Client` struct.
// Assumes "reqwest" feature is enabled (see above)
let client = Client::new(Arc::new(reqwest::Client::new()));

// You'll need an upload URL to be able to upload a files.
// This may be provided to you (through a separate API, for example),
// or you might need to create the file through the *tus* protocol.
// If an upload URL is provided for you, you can skip this step.

let upload_url = client
.create("https://my.tus.server/files/", "/path/to/file").await
.expect("Failed to create file on server");

// Next, you can start uploading the file by calling `upload`.
// The file will be uploaded in 5 MiB chunks by default.
// To customize the chunk size, use `upload_with_chunk_size` instead of `upload`.

client
.upload(&upload_url, "/path/to/file").await
.expect("Failed to upload file to server");

upload (and upload_with_chunk_size) will automatically resume the upload from where it left off, if the upload transfer is interrupted.

Re-exports§

pub use http::HttpHandler;

Modules§

http
Contains the HttpHandler trait and related structs. This module is only relevant when implement HttpHandler manually.

Structs§

Client
Used to interact with a tus endpoint.
ServerInfo
Describes the tus enabled server.
UploadInfo
Describes a file on the server.

Enums§

Error
Enumerates the errors which can occur during operation
TusExtension
Enumerates the extensions to the tus protocol.