Skip to content

Commit

Permalink
updated doctests again
Browse files Browse the repository at this point in the history
  • Loading branch information
0x6e66 committed Jan 29, 2024
1 parent 019e83c commit a588c2b
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@
//!
//!
//! ## Get metadata for a specific PANGAEA dataset
//! ```
//! ```rust,no_run
//! use std::{fs::File, io::Write};
//! use pangaea::elastic::elastic_doc;
//!
//! #[tokio::main]
//! pub async fn main() {
//! let dataset_id = 820322;
//! let metadata = elastic_doc(dataset_id).await.unwrap();
//!
//! let mut file = File::create(format!("pangaea-dataset-{}.json", dataset_id)).unwrap();
//! let json = serde_json::to_string(&metadata).unwrap();
//! write!(file, "{}", json).unwrap();
//! }
//! ```
//!
//! ## Search for multiple datasets
//! ```
//! ```rust,no_run
//! use std::{fs::File, io::Write};
//! use pangaea::elastic::elastic_search;
//!
//! #[tokio::main]
Expand All @@ -27,13 +31,30 @@
//! .await
//! .unwrap();
//!
//! let mut file = File::create(format!("pangaea-datasets.jsonl")).unwrap();
//!
//! res.into_iter()
//! .filter_map(|md_res| md_res.ok())
//! .for_each(|md| {
//! let json = serde_json::to_string(&md).unwrap();
//! writeln!(file, "{}", json).unwrap();
//! });
//! }
//! ```
//!
//!
//! ## Download the actual data associated with the dataset
//! ```rust,no_run
//! use pangaea::download_data::download_data_by_id;
//!
//! #[tokio::main]
//! async fn main() {
//! let id = 921673;
//! download_data_by_id(id, "downloaded_file").await.unwrap();
//! }
//!
//! ```
//! The data will saved to `filename.zip` or `filename.txt`, depending on the datatype that is returned

pub mod download_data;
pub mod elastic;
Expand Down

0 comments on commit a588c2b

Please sign in to comment.