ucare/lib.rs
1#![deny(missing_docs)]
2
3//! The `ucare` crate provides rust client implementation for the Uploadcare REST and upload API.
4//!
5//! ## Usage examples:
6//! ```no_run
7//! # use std::env;
8//! # use env_logger;
9//! # use ucare::file;
10//! # fn main() {
11//! let env = env_logger::Env::default()
12//! .filter_or("MY_LOG_LEVEL", "debug")
13//! .write_style_or("MY_LOG_STYLE", "always");
14//!
15//! env_logger::init_from_env(env);
16//!
17//! let secret_key = env::var("UCARE_SECRET_KEY").unwrap();
18//! let pub_key = env::var("UCARE_PUBLIC_KEY").unwrap();
19//!
20//! let creds = ucare::ApiCreds {
21//! secret_key,
22//! pub_key,
23//! };
24//! let config = ucare::RestConfig {
25//! sign_based_auth: true,
26//! api_version: ucare::RestApiVersion::V05,
27//! };
28//!
29//! let rest_client = ucare::RestClient::new(config, creds).unwrap();
30//!
31//! let file_svc = file::new_svc(&rest_client);
32//!
33//! // getting a list of files
34//! let list_params = file::ListParams{
35//! removed: Some(true),
36//! stored: Some(true),
37//! limit: Some(10),
38//! ordering: Some(file::Ordering::Size),
39//! from: None,
40//! };
41//! let list = file_svc.list(list_params).unwrap();
42//!
43//! // getting file info
44//! let file_id = &list.results.unwrap()[0].uuid;
45//! let file_info = file_svc.info(&file_id).unwrap();
46//!
47//! // store file by its id
48//! file_svc.store(&file_id).unwrap();
49//!
50//! // remove file by its id
51//! file_svc.delete(&file_id).unwrap();
52//! # }
53//! ```
54//!
55//! ## Enable logging:
56//! Library uses `log` crate to log useful information.
57//!
58//! In binary choose a logging implementation and initialize it in the runtime of the program.
59
60mod ucare;
61
62#[cfg(feature = "rest")]
63pub use crate::ucare::rest::{
64 ApiVersion as RestApiVersion, Client as RestClient, Config as RestConfig,
65};
66
67#[cfg(feature = "upload")]
68pub use crate::ucare::upload::{Client as UploadClient, Config as UploadConfig};
69
70#[cfg(feature = "rest")]
71pub mod conversion;
72#[cfg(feature = "rest")]
73pub mod file;
74#[cfg(feature = "rest")]
75pub mod group;
76#[cfg(feature = "rest")]
77pub mod project;
78#[cfg(feature = "rest")]
79pub mod webhook;
80
81#[cfg(feature = "upload")]
82pub mod upload;
83
84pub use crate::ucare::{ApiCreds, ErrValue, Error, Result};