Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding documentation example, fixing typo #188

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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