smartsheet_rs/lib.rs
1// #![deny(warnings)]
2// #![warn(rust_2018_idioms)]
3
4//! [![github]](https://github.com/rnag/smartsheet-rs) [![crates-io]](https://crates.io/crates/smartsheet-rs) [![docs-rs]](https://docs.rs/smartsheet-rs)
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//! [Smartsheet API v2](https://smartsheet-platform.github.io/api-docs/).
14//!
15//! <br>
16//!
17//! ## Example
18//!
19//! ```no_run
20//! use smartsheet_rs::SmartsheetApi;
21//!
22//! #[tokio::main]
23//! async fn main() -> std::result::Result<(), Box<dyn std::error::Error + Send + Sync>> {
24//! let smart = SmartsheetApi::from_env()?;
25//! println!("Created a Smartsheet API client");
26//!
27//! let sheets = smart.list_sheets().await?;
28//!
29//! println!("Printing sheet IDs and names:");
30//! for sheet in sheets.data {
31//! println!(
32//! "{sep}{id:<20}|{sep}{name}",
33//! sep = '\t',
34//! id = sheet.id,
35//! name = sheet.name
36//! );
37//! }
38//!
39//! Ok(())
40//! }
41//! ```
42//!
43//! ## Implemented Methods
44//!
45//! The following API methods from the [official documentation](https://smartsheet-platform.github.io/api-docs)
46//! have been implemented currently:
47//!
48//! - [List Sheets](https://smartsheet-platform.github.io/api-docs/#list-sheets)
49//! - [List Columns](https://smartsheet-platform.github.io/api-docs/#list-columns)
50//! - [List Attachments](https://smartsheet-platform.github.io/api-docs/#list-attachments)
51//! - [Get Sheet](https://smartsheet-platform.github.io/api-docs/#get-sheet)
52//! - [Get Column](https://smartsheet-platform.github.io/api-docs/#get-column)
53//! - [Get Attachment](https://smartsheet-platform.github.io/api-docs/#get-attachment)
54//! - [Get Row](https://smartsheet-platform.github.io/api-docs/#get-row)
55//! - [Add Rows](https://smartsheet-platform.github.io/api-docs/#add-rows)
56//! - [Update Rows](https://smartsheet-platform.github.io/api-docs/#update-rows)
57//! - [Delete Rows](https://smartsheet-platform.github.io/api-docs/#delete-rows)
58//!
59//! You can check out sample usage of these API methods in the [examples/](https://github.com/rnag/smartsheet-rs/tree/main/examples)
60//! folder in the project repo on GitHub.
61//!
62//! ## A Larger Example
63//!
64//! This section contains more examples of usage. You can find it in the readme documentation on the
65//! [crates.io] page, or alternatively in the [`README.md`] file on the GitHub project repo.
66//!
67//! [crates.io]: https://crates.io/crates/smartsheet-rs#a-larger-example
68//! [`README.md`]: https://github.com/rnag/smartsheet-rs#a-larger-example
69//!
70//! ## Dependencies and Features
71//!
72//! This library uses only the minimum required dependencies, in order
73//! to keep the overall size small. This crate uses [hyper][] and
74//! [hyper-rustls][] internally, to make HTTPS requests to the Smartsheet API.
75//!
76//! While `hyper-rustls` was chosen as the default TLS implementation
77//! because it works without issue when cross-compiling for the
78//! **x86_64-unknown-linux-musl** target as is common for [AWS Lambda][]
79//! deployments, it is still possible to instead use the native [`hyper-tls`][]
80//! implementation, which relies on OpenSSL.
81//!
82//! To do this, disable the default "rust-tls" feature and enable the "native-tls" feature:
83//!
84//! ```toml
85//! [dependencies]
86//! smartsheet-rs = { version = "0.6.2", default-features = false, features = ["native-tls", "logging", "serde-std"] }
87//! ```
88//!
89//! [hyper]: https://docs.rs/hyper
90//! [hyper-rustls]: https://docs.rs/hyper-rustls
91//! [`hyper-tls`]: https://docs.rs/hyper-tls
92//! [AWS Lambda]: https://docs.aws.amazon.com/sdk-for-rust/latest/dg/lambda.html
93//!
94
95// #![warn(missing_docs)]
96
97mod features_check;
98
99#[cfg(feature = "logging")]
100mod log {
101 pub use log::{debug, error, trace, warn};
102}
103
104#[cfg(not(feature = "logging"))]
105mod log {
106 macro_rules! debug ( ($($tt:tt)*) => {{}} );
107 macro_rules! error ( ($($tt:tt)*) => {{}} );
108 macro_rules! trace ( ($($tt:tt)*) => {{}} );
109 macro_rules! warning ( ($($tt:tt)*) => {{}} );
110 pub(crate) use {debug, error, trace, warning as warn};
111}
112
113pub use api::SmartsheetApi;
114pub use cell_factory::CellFactory;
115pub use helpers::{CellGetter, ColumnMapper, RowGetter};
116
117mod api;
118pub mod auth;
119pub mod builders;
120mod cell_factory;
121pub mod constants;
122pub mod helpers;
123mod https;
124pub mod models;
125pub mod status;
126pub mod types;
127pub mod utils;
128
129#[cfg(test)]
130mod tests {
131 #[test]
132 fn it_works() {
133 let result = 2 + 2;
134 assert_eq!(result, 4);
135 }
136}