From 5a17d61bf3cb9102575afa6d8540e7b184270db7 Mon Sep 17 00:00:00 2001 From: Travis Hathaway Date: Fri, 5 May 2023 17:12:42 +0200 Subject: [PATCH 1/2] Adding documentation example, fixing typo --- .../rattler_repodata_gateway/src/fetch/mod.rs | 2 +- crates/rattler_repodata_gateway/src/lib.rs | 54 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/crates/rattler_repodata_gateway/src/fetch/mod.rs b/crates/rattler_repodata_gateway/src/fetch/mod.rs index ca4f69d94..0a16732da 100644 --- a/crates/rattler_repodata_gateway/src/fetch/mod.rs +++ b/crates/rattler_repodata_gateway/src/fetch/mod.rs @@ -238,7 +238,7 @@ async fn repodata_from_file( /// /// The successful result of this function also returns a lockfile which ensures that both the state /// and the repodata that is pointed to remain in sync. However, not releasing the lockfile (by -/// dropping it) could block other threads and processes, it is therefor advices to release it as +/// dropping it) could block other threads and processes, it is therefore advisable to release it as /// quickly as possible. /// /// This method implements several different methods to download the repodata.json file from the diff --git a/crates/rattler_repodata_gateway/src/lib.rs b/crates/rattler_repodata_gateway/src/lib.rs index 675a23f1e..2e6c6798a 100644 --- a/crates/rattler_repodata_gateway/src/lib.rs +++ b/crates/rattler_repodata_gateway/src/lib.rs @@ -6,6 +6,60 @@ //! //! In the future this crate will also provide more high-level functionality to query information //! about specific packages from different sources. +//! +//! # Install +//! +//! Add the following to your *Cargo.toml*: +//! +//! ```toml +//! [dependencies] +//! rattler_repodata_gateway = "0.2.0" +//! ``` +//! +//! or run +//! +//! ```bash +//! cargo add rattler_repodata_gateway +//! ``` +//! +//! # Examples +//! +//! Below is a basic example that shows how to retrieve and cache the repodata for a conda channel +//! using the [`fetch::fetch_repo_data`] function: +//! +//! ```rust +//! use std::{path::Path, default::Default}; +//! use reqwest::Client; +//! use url::Url; +//! use rattler_repodata_gateway::fetch; +//! +//! #[tokio::main] +//! async fn main() { +//! let repodata_url = Url::parse("https://conda.anaconda.org/conda-forge/osx-64/").unwrap(); +//! +//! let client = Client::new(); +//! let cache = Path::new("./cache"); +//! +//! let result = fetch::fetch_repo_data( +//! repodata_url, +//! client, +//! cache, +//! fetch::FetchRepoDataOptions { ..Default::default() } +//! ).await; +//! +//! let result = match result { +//! Err(err) => { +//! panic!("{:?}", err); +//! }, +//! Ok(result) => result +//! }; +//! +//! println!("{:?}", result.cache_state); +//! println!("{:?}", result.cache_result); +//! println!("{:?}", result.lock_file); +//! println!("{:?}", result.repo_data_json_path); +//! } +//! ``` pub mod fetch; #[cfg(feature = "sparse")] From b3c9ab707cb07eadaa2ee21886c89904ec2dd991 Mon Sep 17 00:00:00 2001 From: Travis Hathaway Date: Fri, 5 May 2023 17:27:19 +0200 Subject: [PATCH 2/2] fixing formatting issues --- crates/rattler_repodata_gateway/src/lib.rs | 23 ++++++++++------------ 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/crates/rattler_repodata_gateway/src/lib.rs b/crates/rattler_repodata_gateway/src/lib.rs index 2e6c6798a..454c59ee0 100644 --- a/crates/rattler_repodata_gateway/src/lib.rs +++ b/crates/rattler_repodata_gateway/src/lib.rs @@ -6,54 +6,51 @@ //! //! In the future this crate will also provide more high-level functionality to query information //! about specific packages from different sources. -//! +//! //! # Install -//! //! Add the following to your *Cargo.toml*: -//! +//! //! ```toml //! [dependencies] //! rattler_repodata_gateway = "0.2.0" //! ``` -//! +//! //! or run -//! +//! //! ```bash //! cargo add rattler_repodata_gateway //! ``` -//! +//! //! # Examples -//! //! Below is a basic example that shows how to retrieve and cache the repodata for a conda channel //! using the [`fetch::fetch_repo_data`] function: -//! +//! //! ```rust //! use std::{path::Path, default::Default}; //! use reqwest::Client; //! use url::Url; //! use rattler_repodata_gateway::fetch; -//! +//! //! #[tokio::main] //! async fn main() { //! let repodata_url = Url::parse("https://conda.anaconda.org/conda-forge/osx-64/").unwrap(); -//! //! let client = Client::new(); //! let cache = Path::new("./cache"); -//! +//! //! let result = fetch::fetch_repo_data( //! repodata_url, //! client, //! cache, //! fetch::FetchRepoDataOptions { ..Default::default() } //! ).await; -//! +//! //! let result = match result { //! Err(err) => { //! panic!("{:?}", err); //! }, //! Ok(result) => result //! }; -//! +//! //! println!("{:?}", result.cache_state); //! println!("{:?}", result.cache_result); //! println!("{:?}", result.lock_file);