gload 0.5.1

A command line client for the Gemini protocol.
Documentation
//! # gload
//!
//! A client library for the Gemini network protocol, designed mainly for use
//! in the gload CLI.
//!
//! There are two functions, [`fetch`] and [`fetch_sync`]; each makes a TLS request to a
//! Gemini capsule and returns the response. Their behavior is the same, except
//! `fetch_sync` is not `async` and cannot be used in a `tokio` runtime.
//!
//! ## Example
//! ```no_run
//! use gload::{Request, fetch};
//! use mediatype::MediaType;
//! use url_static::url;
//!
//! # #[tokio::main]
//! # async fn main() {
//! let request = Request::new(url!("gemini://git.average.name/AverageHelper/gload")).unwrap();
//! let response = fetch(request, Default::default()).await.unwrap();
//!
//! // Check the response status
//! assert!(response.is_success()); // `true` if the status is 20
//!
//! // Parse the response header
//! let meta = response.meta().unwrap(); // e.g. "text/gemini; charset=UTF-8; lang=en", always nonempty if `Some`
//! let mime_type = MediaType::parse(meta).unwrap();
//! assert_eq!(mime_type.essence().ty.as_str(), "text");
//! assert_eq!(mime_type.essence().subty.as_str(), "gemini");
//!
//! // Read the response body
//! let body = response.body().unwrap(); // always non-empty if `Some`
//! let text = str::from_utf8(body).unwrap(); // e.g. "Hello, world!" with or without trailing newlines
//! # }
//! ```
//!
//! There is also a sync API.
//! ```no_run
//! # use gload::{Request, fetch_sync};
//! # use url_static::url;
//! # let request = Request::new(url!("gemini://git.average.name/AverageHelper/gload")).unwrap();
//! let response = fetch_sync(request, Default::default()).unwrap();
//! ```
//!
#![cfg_attr(all(doc, not(doctest)), doc = "## Crate Features")]
#![cfg_attr(all(doc, not(doctest)), doc = "The gload crate exposes only one build feature.")]
#![cfg_attr(all(doc, not(doctest)), doc = document_features::document_features!())]
#![cfg_attr(docsrs, feature(doc_cfg))]

pub mod net;
pub mod request;
pub mod response;
pub mod tls;

pub use net::{FetchOptions, fetch, fetch_sync};
pub use request::Request;
pub use response::Response;

#[cfg(test)]
mod test_server;