Skip to content

Commit

Permalink
Adding documentation example, fixing typo (#188)
Browse files Browse the repository at this point in the history
* Adding documentation example, fixing typo

* fixing formatting issues
  • Loading branch information
travishathaway authored May 5, 2023
1 parent aa46f5a commit 0d26cda
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/rattler_repodata_gateway/src/fetch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 51 additions & 0 deletions crates/rattler_repodata_gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,57 @@
//!
//! 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")]
Expand Down

0 comments on commit 0d26cda

Please sign in to comment.