smartsheet-rs
smartsheet-rs is a rust crate which provides an async wrapper API that lets you easily interact
with the Smartsheet API 2.0.
This is an unofficial SDK I have made to learn Rust a little, but I hope you have fun with it -- I know that I certainly had quite a bit of fun in writing out the implementation for this crate.
Table of Contents
- Getting Started
- Implemented Methods
- A Larger Example
- Dependencies and Features
- Contributing
- License
- Authors
Getting Started
Getting started with the smartsheet-rs library is easy:
-
Set SMARTSHEET_ACCESS_TOKEN in your environment; you can also use the
SmartsheetApi::from_tokenconstructor to explicitly set the token value. Find out more about Authentication and Access Tokens in the Smartsheet API Documentation. -
Add these dependencies to your
Cargo.toml:[] = "0.3" = { = "1", = ["rt-multi-thread", "macros"] } -
Add some usage to your application:
use SmartsheetApi; async
Implemented Methods
The following API methods from the official documentation have been implemented currently:
You can check out sample usage of these API methods in the examples/ folder in the project repo on GitHub.
A Larger Example
When working with rows and cells in the SmartSheet API, one thing that stands out is that the API purposefully identifies columns by their ID, rather than their title or column name.
However, as humans it's much more natural and convenient to refer to column names
when working with the data.
Towards that end, the smartsheet-rs crate provides helper struct implementations
such as the ColumnMapper and CellGetter in order to simplify interaction
with the Smartsheet API.
Here's a quick example of how that would work:
use ;
// TODO update these values as needed
const SHEET_ID: u64 = 1234567890;
const COLUMN_NAME: &str = "My Column";
// A simple type alias so as to DRY.
type Result<T> = Result;
async
The CellGetter::by_name method works by iterating over each cell in the row,
and then returning the first Cell where the column ID for the cell
matches the specified column name.
If the need arises to retrieve multiple Cell objects from a Row by their column names,
it might be a better idea to first build out a mapping of each column name to the
Cell object in the row for that column. The method CellGetter::name_to_cell can be used
for this purpose, as shown below.
let column_name_to_cell = get_cell.name_to_cell;
println!;
// Prints:
// {
// "Column 1": Cell {...},
// "Column 2": Cell {...},
// ...
Dependencies and Features
This library uses only the minimum required dependencies, in order
to keep the overall size small. This crate uses hyper and hyper-rustls
internally, to make HTTPS requests to the Smartsheet API.
While hyper-rustls was chosen as the default TLS implementation
because it works without issue when cross-compiling for the
x86_64-unknown-linux-musl target as is common for AWS Lambda
deployments, it is still possible to instead use the native hyper-tls
implementation, which relies on OpenSSL.
To do this, disable the default "rust-tls" feature and enable the "native-tls" feature:
[]
= { = "0.3", = false, = ["native-tls", "logging", "serde-std"] }
Contributing
Contributions are welcome! Open a pull request to fix a bug, or open an issue to discuss a new feature or change.
Check out the Contributing section in the docs for more info.
License
This project is proudly licensed under the MIT license (LICENSE or http://opensource.org/licenses/MIT).
smartsheet-rs can be distributed according to the MIT license. Contributions
will be accepted under the same license.