rust_wistia/
lib.rs

1// #![deny(warnings)]
2// #![warn(rust_2018_idioms)]
3
4//! [![github]](https://github.com/rnag/rust-wistia) [![crates-io]](https://crates.io/crates/rust-wistia) [![docs-rs]](https://docs.rs/rust-wistia)
5//!
6//! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
7//! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust
8//! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K
9//!
10//! <br>
11//!
12//! An async Rust library implementation to interact with the
13//! [Wistia API](https://wistia.com/support/developers).
14//!
15//! <br>
16//!
17//! # Example
18//!
19//! ```no_run
20//! use rust_wistia::UrlUploader;
21//!
22//! #[tokio::main]
23//! async fn main() -> std::result::Result<(), Box<dyn std::error::Error + Send + Sync>> {
24//!     let res = UrlUploader::new("my-url-link")?
25//!         .name("My Video Name")
26//!         .send()
27//!         .await?;
28//!
29//!     println!("Response: {res:#?}");
30//!
31//!     // Print out some useful attributes
32//!     println!("Video ID: {}", res.hashed_id);
33//!
34//!     Ok(())
35//! }
36//! ```
37//!
38//! # Dependencies and Features
39//!
40//! This library uses only the minimum required dependencies, in order
41//! to keep the overall size small. This crate uses [hyper] and
42//! [hyper-rustls] internally, to make HTTPS requests to the Wistia API.
43//!
44//! While `hyper-rustls` was chosen as the default TLS implementation
45//! because it works without issue when cross-compiling for the
46//! **x86_64-unknown-linux-musl** target as is common for [AWS Lambda][]
47//! deployments, it is still possible to instead use the native [`hyper-tls`][]
48//! implementation, which relies on OpenSSL.
49//!
50//! To do this, disable the default "rust-tls" feature and enable the "native-tls" feature:
51//!
52//! ```toml
53//! [dependencies]
54//! rust-wistia = { version = "0.8", default-features = false, features = ["native-tls", "logging", "serde-std"] }
55//! ```
56//!
57//! [hyper]: https://docs.rs/hyper
58//! [hyper-rustls]: https://docs.rs/hyper-rustls
59//! [`hyper-tls`]: https://docs.rs/hyper-tls
60//! [AWS Lambda]: https://docs.aws.amazon.com/sdk-for-rust/latest/dg/lambda.html
61//!
62
63mod api;
64pub mod auth;
65pub mod constants;
66pub mod https;
67pub mod models;
68pub mod status;
69pub mod types;
70pub mod utils;
71
72pub use api::*;
73pub use https::tls;
74pub use models::error::*;
75pub use types::*;
76
77#[cfg(feature = "logging")]
78mod log {
79    pub use log::{debug, error, trace, warn};
80}
81
82#[cfg(not(feature = "logging"))]
83mod log {
84    macro_rules! debug      ( ($($tt:tt)*) => {{}} );
85    macro_rules! error      ( ($($tt:tt)*) => {{}} );
86    macro_rules! trace      ( ($($tt:tt)*) => {{}} );
87    macro_rules! warning    ( ($($tt:tt)*) => {{}} );
88    pub(crate) use {debug, error, trace, warning as warn};
89}
90
91#[cfg(test)]
92mod tests {
93    #[test]
94    fn it_works() {
95        let result = 2 + 2;
96        assert_eq!(result, 4);
97    }
98}