Crate ucare

Source
Expand description

The ucare crate provides rust client implementation for the Uploadcare REST and upload API.

§Usage examples:

let env = env_logger::Env::default()
    .filter_or("MY_LOG_LEVEL", "debug")
    .write_style_or("MY_LOG_STYLE", "always");

env_logger::init_from_env(env);

let secret_key = env::var("UCARE_SECRET_KEY").unwrap();
let pub_key = env::var("UCARE_PUBLIC_KEY").unwrap();

let creds = ucare::ApiCreds {
    secret_key,
    pub_key,
};
let config = ucare::RestConfig {
    sign_based_auth: true,
    api_version: ucare::RestApiVersion::V05,
};

let rest_client = ucare::RestClient::new(config, creds).unwrap();

let file_svc = file::new_svc(&rest_client);

// getting a list of files
let list_params = file::ListParams{
    removed: Some(true),
    stored: Some(true),
    limit: Some(10),
    ordering: Some(file::Ordering::Size),
    from: None,
};
let list = file_svc.list(list_params).unwrap();

// getting file info
let file_id = &list.results.unwrap()[0].uuid;
let file_info = file_svc.info(&file_id).unwrap();

// store file by its id
file_svc.store(&file_id).unwrap();

// remove file by its id
file_svc.delete(&file_id).unwrap();

§Enable logging:

Library uses log crate to log useful information.

In binary choose a logging implementation and initialize it in the runtime of the program.

Modules§

conversion
Holds all primitives and logic related to file conversion.
file
Holds all primitives and logic around the file resource.
group
Holds all primitives and logic related file entity.
project
Holds all primitives and logic around the project resource.
upload
Upload module contains all upload related API stuff.
webhook
Holds all primitives and logic around the webhook resource.

Structs§

ApiCreds
Holds per project API credentials. You can find your credentials on the uploadcare dashboard.
Error
Represents library level error
RestClient
Client is responsible for preparing requests and making http calls.
RestConfig
Configuration for the client.
UploadClient
Client is responsible for preparing requests and making http calls.
UploadConfig
Configuration for the client.

Enums§

ErrValue
Represents possible errors returned by the library
RestApiVersion
Available API versions for client to specify when making requests.

Type Aliases§

Result
Result has Error as default value for Err value