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§

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

Structs§

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

Enums§

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

Type Aliases§

  • Result has Error as default value for Err value